I'm using the write_xlsx command to export data from R to excel,
Here is the data frame that I have,
>df
X1
A 76
B 78
C 10
Using ,
write_xlsx(df, "../mydata.xlsx")
gives the following output in excel,
>df
1 76
2 78
3 10
The column names appear in the xlsx file but the index of each row isn't printed. Is there any way to print the row index in the excel file?
writexl::write_xlsx()
as that's the only package that I found with a search. Doesn't look like there's an option to include row names in that one. You have two options: include the row names as a column in the data (preferred), or use a different package, e.g.openxlsx::write.xlsx(head(mtcars), "test.xlsx", row.names = TRUE)
. – Agraphia