用r的xlsx包出现java.lang.OutOfMemoryError: GC overhead limit exceeded怎么办

用xlsx包写出数据时遇到了如下的报错

Error in .jnew("org/apache/poi/xssf/usermodel/XSSFWorkbook") : 
  java.lang.OutOfMemoryError: GC overhead limit exceeded

第一种处理方法,提高Java的运行内存

options(java.parameters = "-Xmx4096m")

如果第一种方法不行,我们可以用openxlsx包,代码如下

require(openxlsx)
list_of_datasets <- list("Name of DataSheet1" = dataframe1, "Name of Datasheet2" = dataframe2)
write.xlsx(list_of_datasets, file = "writeXLSX2.xlsx"

参考资料: https://stackoverflow.com/questions/27713310/easy-way-to-export-multiple-data-frame-to-multiple-excel-worksheets

你可能感兴趣的:(用r的xlsx包出现java.lang.OutOfMemoryError: GC overhead limit exceeded怎么办)