how to fix "Error in textConnection(text) : all connections are in use" in R?

In R I tried to read a fairly large csv file (4200KB) but encountered the following error. It is strange that I ran the same command before without any problem. The only thing changed was I recently updated my R from 3.01 to 3.03. Not sure this would affect anything.

If anyone has a thought/experience on how to fix it, it would be much appreciated!

> xml2csv(xmlFile,csvFile)

 Error in textConnection(text) : all connections are in use 

>traceback()

9 textConnection(text) 

8 read.table(text = data, sep = sep, fill = TRUE, row.names = NULL, 
    header = FALSE, blank.lines.skip = FALSE, strip.white = TRUE, 
    col.names = paste("v", sequence(max(x)))) 

7 read.concat(a, names(data[split.col]), sep) 

6 concat.split.compact(data = data, split.col = split.col, sep = sep, 
    drop = drop, fixed = fixed) 

5 concat.split(data[split.cols[x]], split.cols[x], seps[x], drop = TRUE) 

4 FUN(1:686[[125L]], ...) 

3 lapply(seq_along(split.cols), function(x) {
    concat.split(data[split.cols[x]], split.cols[x], seps[x], 
        drop = TRUE)
}) 

2 concat.split.multiple(Y, as.vector(colnames(Y))[-c(1:2)], ":") at IFN_functions.r#115

1 xml2csv(xmlFile, csvFile)

Answers


The error message is fairly self-explanatory; all text connections are in use :). Are you using other connections in the code? And if so, are you closing them after you're done with them with close(con)?


The limit of maximum number of open connections is currently set to be 128. It is hardcoded into the R source code as constant / macro NCONNECTIONS in src/main/connections.c

You may look at the workaround posted on Wishlist for R: https://github.com/HenrikBengtsson/Wishlist-for-R/issues/28


Need Your Help

JQuery FadeIn/Out Only Works One Time

javascript jquery css

I have a very simply div that uses JQuery to fade in when the mouse hovers over the div. Then when the mouse leaves the div it fades back out.

JSON multi dimensional array not displaying ('array is not defined')

javascript ajax json

I made some edits to my returned JSON array and now it broke the code. Essentially, all I did was turn it into a multi-dimensional array (2?)