readxl not compatible with openxlsx
luisvalenzuelar opened this issue · 1 comments
luisvalenzuelar commented
Hi there,
readxl
does not preserve the class of a dataframe saved with openxslx
package. Since readxl
does not create xlsx files, one must use a package like openxlsx
. But since the latter also opens xlsx files and does preserve class, ones asks why readxl
is needed at all. It would be better if readxl
could preserve the class of created excel files.
# create dataframe
df <- data.frame("var" = c(seq(1,10)))
class(df) # results is "data.frame"
# Export as xlsx
library(openxlsx)
write.xlsx(df,"df.xlsx", overwrite = TRUE)
# Import as xlsx
library(readxl)
df <- read_excel("df.xlsx")
# Check class of imported object
class(df) # results is "tbl_df" "tbl" "data.frame"
jennybc commented
readxl returns a "tibble", which is a sub-class of data.frame
.
ones asks why readxl is needed at all
readxl is one of the most downloaded packages on CRAN, so many people do find it useful. You are welcome to use openxlsx if you wish.