Reputation: 23
I am using the function write.xlsx to convert a data frame to an xlsx file ( In R 3.6.1) . The dataframe I am looking at has NA's in some of the rows, however when I save the dataframe as an xlsx file they appear as blank cells, I have tried using the optional argument showNA but this doesn't work, I have also tried the function write_xlsx but this doesn't have that argument.
Any help appreciated - Thanks!
Upvotes: 2
Views: 2104
Reputation: 887691
We could specify the keepNA
argument in write.xlsx
. According to the ?write.xlsx
keepNA - If TRUE, NA values are converted to #N/A (or na.string, if not NULL) in Excel, else NA cells will be empty
openxlsx::write.xlsx(df1, 'yourfile.xlsx', keepNA = TRUE)
Upvotes: 2