Reputation: 35
can anyone help me with how to export the result of comparedf()
from the arsenal package to an Excel file?
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'
Upvotes: 2
Views: 2803
Reputation: 388797
diffs
function returns certain columns of class 'AsIs'
which is of type list.
unlist
those columns into a vector before writing them to Excel.
diff[] <- lapply(diff, function(x) if(class(x) == 'AsIs') unlist(x) else x)
openxlsx::write.xlsx(diff, "diff.xlsx")
Upvotes: 2