R:OutOfMemoryError(Java):超出GC开销限制

时间:2018-03-31 05:33:32

标签: r excel matrix lookup xls

我有一个脚本可以从矩阵中查找值并填充同一xls工作簿中不同工作表中的单元格。我遇到错误:OutOfMemoryError(Java):代码运行时间之间超出了GC开销限制。下面提到的是代码,任何支持纠正这个问题都将非常感谢。谢谢。

require(XLConnect)
wb = loadWorkbook("F:/Projects/QC_QA_TEMP/template.xlsx")
memory.size()
rawdata = readWorksheet(wb, sheet = "Complete Users Report", header = TRUE)
str(rawdata)
city<-unique(rawdata$Location)

df = readWorksheet(wb, sheet = "Category 15 a", header = TRUE)

df$City
question<-colnames(df)
question<-question[-c(1,2)]
result<-matrix(nrow = length(city), ncol =length(question))

str(result)
for (i in 1:length(city)){
  for (j in 1:length(question)){
    a <- subset(rawdata,Location==city[i] & Question==question[j])
    result[i,j]<-a$Response[1]

  }
} 
str(result)
summary(result)
writeWorksheet(wb,result,"Category 15 a",startRow = 3, startCol = 3, header = FALSE)

0 个答案:

没有答案