Re: [Rd] Enhancement request: anonymous connections

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Wed 28 Dec 2005 - 01:44:40 GMT

On 12/27/2005 7:59 PM, Seth Falcon wrote:
> I would like to be able to use anonymous connections in R and have
> them close themselves when they go out of scope.
>
> Here is an example of what I think should work, but does not at
> present:
>
> ## create test file
> x <- 1:10
> fn <- "anon-con-test-x.rda"
> save(x, file=fn)
> testUrl <- paste("file:/", getwd(), fn, sep="/")
>
> ## use an anonymous connection to load data from
> ## the URL as suggested in help(load).
> for (i in 1:50) {
> print(load(url(testUrl)))
> }
>
> [snip some output]
> Error in url(testUrl) : all connections are in use
>
> If such a feature is not possible/desired for the next release, it
> might be good to add a note to the documentation for connections that
> mentions this issue with anonymous connections.

This is a bug in load, isn't it? load() opens the connection but doesn't close it.

I think a fix is to add a line to load() as shown below:

Index: load.R


      magic <- readChar(con, 5)

Duncan Murdoch



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Dec 28 12:54:43 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:35 GMT