我在不同的目录中有一组 csv 文件,我想将它们全部放在一个 excel 文件中,每个表都放在一个 excel 表中。
我正在使用 R 和 xlsx 包。
# loading the library
library(xlsx)
rm(list = ls())
# getting the path of all reports (they are in csv format)
restab = system("ls /home/ubuntu/ibasruns/control/*/report",intern = TRUE)
# creating work book
wb <- createWorkbook()
# going through each csv file
for (item in restab)
{
# making each as a sheet
sheet <- createSheet(wb, sheetName=strsplit(item,"/")[[1]][6])
addDataFrame(read.csv(item), sheet)
# saving the workbook
saveWorkbook(wb, "AliceResultSummary.xlsx")
}
# finally writing it.
write.xlsx(wb, "AliceResultSummary.xlsx")
但是,在最后一行,我收到以下错误,
as.data.frame.default(x[[i]], optional = TRUE) 中的错误:无法将类“结构(“jobjRef”,包 =“rJava”)”强制转换为 data.frame
有什么我想念的吗?