Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 将数据集导出到xslx并包含筛选器_R - Fatal编程技术网

R 将数据集导出到xslx并包含筛选器

R 将数据集导出到xslx并包含筛选器,r,R,我正试图从数据集18列中创建一个xlsx文件。似乎无法使用筛选器标志。创建的文件确实有我需要的固定行,但没有筛选器 write.xlsx(main.df, "febrero2021.xlsx", row.names = FALSE, firstActiveRow=2, colWidths = "auto", withFilter = c(TR

我正试图从数据集18列中创建一个xlsx文件。似乎无法使用筛选器标志。创建的文件确实有我需要的固定行,但没有筛选器

write.xlsx(main.df, 
           "febrero2021.xlsx",
           row.names = FALSE, 
           firstActiveRow=2, 
           colWidths = "auto",
           withFilter = c(TRUE, TRUE, TRUE,
                          TRUE, TRUE, TRUE,
                          TRUE, TRUE, TRUE,
                          TRUE, TRUE, TRUE,
                          TRUE, TRUE, TRUE,
                          TRUE, TRUE, TRUE))
尝试:


我怀疑这是openxlsx中的一个bug,因为根据?write.xlsx。。。应该传递给writeData,我推断,writeData是可写的

无论如何,我可以证实这种行为。以下两个命令

write.xlsxmtcars,mt.xlsx,asTable=TRUE,row.names=FALSE, firstActiveRow=2,colWidths=auto,withFilter=FALSE write.xlsxmtcars,mt.xlsx,asTable=TRUE,row.names=FALSE, firstActiveRow=2,colWidths=auto,withFilter=TRUE 产生

坦率地说,它看起来不仅仅是受filter=的影响。。。colWidths=auto也没有被传递

但是,如果您使用WriteDataable手动创建它,它将正常工作


wb对我来说,这不会改变行为。这不会解决我的问题。这可能是您试图放入excel工作表中的对象的类有问题。你能举个简单的例子说明你的数据吗?谢谢。对于firstActiveRow=2,colWidths=auto的标志有什么解决方法吗?不幸的是,它们看起来不是可写的。顺便说一句:我提交了一份关于这个的bug报告。我建议您在那里添加一个功能请求,将这两个选项添加到WriteDataable。它似乎是固定的:未测试。
write.xlsx(main.df, 
           "febrero2021.xlsx",
           asTable = TRUE,
           row.names = FALSE, 
           firstActiveRow=2, 
           colWidths = "auto",
           withFilter = TRUE)