0

我正在尝试使用Rmarkdown生成一个 html 报告,并希望包含多个rpivotTable。我已将输入 data.tables 存储在一个列表中,其长度可以根据我生成报告的数据而变化,我想遍历列表中的每个元素并将其打印在 html 中。

任何帮助将不胜感激!

DT1 <- data.table(A= c(1,1,1), B= c(2,2,2))
DT2 <- data.table(C= c(3,3,3), D= c(4,4,4))
    
pivot_list <- list (DT1, DT2)

## This works and will include two rpivotTables in the html
rpivotTable(pivot_list[[1]])
rpivotTable(pivot_list[[2]])

## This doesn't work and won't include any tables in the html
for (i in 1:length(pivot_list)) {
      rpivotTable(pivot_list[[i]])
}

谢谢!

本尼迪克特

4

0 回答 0