0

I've got a dataframe in R that has around 34000 rows and 10 columns. Some of these columns contain strings. When I try to export to Excel or csv (either via write.xlsx or write.csv or write.table) and then open the file, the results file does not open properly. The format looks very messy and unreadable.

Has anyone got any tips for exporting an R dataframe to Excel or csv, and opening it without any formatting errors in the Excel view?

3
  • Might be worthwhile trying out the readr equivalents. For example write_excel_csv() seems to be applicable in your situation. Commented Sep 16, 2020 at 13:39
  • Thanks. I tried to use it, but the format on opening the file is still not right. Commented Sep 16, 2020 at 14:21
  • The first 900 rows look fine, then the format gets messy Commented Sep 16, 2020 at 14:23

1 Answer 1

1

Have you tried with openxlsx library

library(openxlsx)
XLSX <- createWorkbook()
addWorksheet(XLSX, "Page name")
writeData(XLSX, "Page name", your_dataframe, startRow = 1, startCol = 1)
saveWorkbook(XLSX, file = "path/data.xlsx", overwrite = TRUE)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.