我有两个不同的数据框,其中包含行和列的变量no。 例如: -
exceldataframe <- data.frame(matrix(ncol = 8, nrow = 0), stringsAsFactors=F)
colnames(exceldataframe) <- c( "Subject", "Session", "thermal data", "pp", "HR", "BR", "peda","performance(res)")
wb = loadWorkbook("MYDataSet.xlsx", create = TRUE)
createSheet(wb, name = "DataSheet")
statisticsFrame <- data.frame(matrix(ncol = 6, nrow = 5), stringsAsFactors=F)
colnames(statisticsFrame) <- c("thermal data", "pp", "HR", "BR", "peda","performance(res)")
row.names(statisticsFrame) <- c("Valid", "Invalid", "Missing", "Not Applicable", "Sum")
我想首先编写exceldataframe,然后在某些行之后追加统计框架。虽然统计框架被附加但我想在第一帧之后留出空格,即excel数据帧。另外,我想在追加统计数据框的同时命名excel行。像行一样应该被命名为Valid,Invalid等。 我写了以下代码: -
writeWorksheet(wb, exceldataframe, sheet = "DataSheet", startRow = 1, startCol = 1)
print(statisticsFrame)
appendWorksheet(wb,statisticsFrame, sheet = "DataSheet", header = TRUE, rownames = TRUE)
saveWorkbook(wb)
这会附加文件,但即使在rownames = TRUE之后也没有显示rownames。谢谢!