Write data into a specific workbook sheet

前端 未结 3 1720
温柔的废话
温柔的废话 2021-01-15 05:38

I have a data frame e.g.

a=1:10 
b=31:40
c=data.frame(a=a,b=b)

and I will need to write this data frame into a specific Excel sheet (\"Shee

3条回答
  •  一向
    一向 (楼主)
    2021-01-15 06:27

    You can simply write into a new sheet of an existing Excel file without modifiying the existing sheets or any other information by doing it this way:

    library(xlsx)
    a=1:10 
    b=31:40
    c=data.frame(a=a,b=b)
    
    write.xlsx(c, "existing_Excel_file.xlsx", sheetName="New sheet name",  append=TRUE)
    

    Remember to set the append argument of write.xlsx to TRUE and make sure the Excel file you are writing in to is in your current working Directory.

提交回复
热议问题