How to avoid writing a row.names column when saving a data.frame using the xlsx package

前端 未结 1 1288
滥情空心
滥情空心 2021-02-04 04:47

I have a data frame like this one below and I really want to remove the row names when I export it to a excel file using the xlsx package.

bd <- data.frame(id         


        
相关标签:
1条回答
  • 2021-02-04 05:16

    Set the rownames to NULL to remove them:

    rownames(bd) <- NULL
    

    Also, from xlsx documentation:

    write.xlsx(x, file, sheetName="Sheet1",
               col.names=TRUE, row.names=TRUE, append=FALSE)
    

    Set row.names to FALSE to avoid the first column being row names.

    0 讨论(0)
提交回复
热议问题