简体   繁体   English

将结果 R 数据框导出到一个 Excel 文件中

[英]Export result R data frame into an Excel file

can anyone help me with how to export the result of comparedf() from the arsenal package to an Excel file?任何人都可以帮助我如何将 comparef comparedf()的结果从军火库package 导出到 Excel 文件?

Here is my script:这是我的脚本:

diff <- diffs(comparedf(mtcars[1:10, ], mtcars[2:11,]))
openxlsx::write.xlsx(diff, "diff.xlsx")

The error message is Error in is.nan(tmp): default method not implemented for type 'list'错误消息是Error in is.nan(tmp): default method not implemented for type 'list'

diffs function returns certain columns of class 'AsIs' which is of type list. diffs function 返回列表类型的 class 'AsIs'某些列。

unlist those columns into a vector before writing them to Excel.在将这些列写入unlist之前将它们取消列出到一个向量中。

diff[] <- lapply(diff, function(x) if(class(x) == 'AsIs') unlist(x) else x)
openxlsx::write.xlsx(diff, "diff.xlsx")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM