我有一个用户定义的功能:
xml2csv = function(inputFile,outputFile) {
X <- read.table(inputFile, header = FALSE, fill = TRUE,sep=" ")
#step1: seperate cell by one or more space
Y <- concat.split.multiple(X, as.vector(colnames(X)), "")
#step2: seperate cell by ":"
Z <- concat.split.multiple(Y, as.vector(colnames(Y))[-c(1:2)], ":")
#delete repeat rows
U=Z[!Z[,1] == "__REPEAT__", ]
#convert factor column as character
V <- data.frame(lapply(U, as.character), stringsAsFactors=FALSE)
W = V
W[is.na(W)] = 0
write.csv(W, outputFile, quote = F, row.names = F)
}
对于小输入文件它完全正常;当输入文件很大(> 2000kb)时,会出现以下错误:
Error in textConnection(text, encoding = "UTF-8") : all connections are in use
有什么建议吗?
答案 0 :(得分:3)
很难确切地知道发生了什么(你的错误是不可重复的!),但是如果concat.split.multiple
中有太多列,我的钱就是X
的错误/限制,因为
concat.split
,lapply
textConnection
,