13  Read and Write Excel Data

Two popular packages to read Excel .xlsx files in R are:

13.1 Read .xslx

13.1.1 openxlsx::read.xlsx()

NA strings are defined with argument na.strings.

bcw <- openxlsx::read.xlsx("../Data/bcw.xlsx", na.strings = ".")

13.1.2 readxl::read_xlsx()

NA strings are defined with argument na.

bcw <- readxl::read_xlsx("../Data/bcw.xlsx", na = ".")

13.2 Write .xlsx

13.2.1 openxlsx::write.xlsx()

openxlsx::write.xlsx(bcw, "../Data/bcw.xlsx")

Note: The readxl package does not include a function to write .XLSX files.