Subject: Re: [R] "problem" with delay()
From: Ray Brownrigg (Ray.Brownrigg@mcs.vuw.ac.nz)
Date: Mon 03 Jul 2000 - 07:53:51 EST
Message-Id: <200007022153.JAA25064@aqua.mcs.vuw.ac.nz>
I asked:
> > I have been using delay() quite successfully to 'load on reference'
> > some large data files (earthquake catalogues). One minor difficulty I
> > have not been able to overcome is that upon first reference, the data
> > set is loaded into memory as expected, but also remains as a permanent
> > object in the user's environment, instead of appearing to be only in
> > the library from which it was loaded.
>
Thomas Lumley <thomas@biostat.washington.edu> replied:
> Your problem is that data() does load the object into the global
> environment. To put data in another environment you need to use load(),
> source(), read.table() &c, explicitly.
>
> :
>
> Alternatively, if your data are in the R save() format and you are using
> 1.1.0 or newer you can delay an attach command
>
> test.x<-delay({attach("data.rda")})
>
> or if the file is in the data subdirectory of "mypackage"
>
> test.x<-delay({attach(system.file("data","data.rda",pkg="mypackage"))})
>
> This loads the file into a new environment in the search path, so it won't
> be saved on exit.
>
[Almost] exactly what I wanted. The above does not actually provide the
value on first reference, so the minor modification to:
test.x<-delay({attach(system.file("data","data.rda",pkg="mypackage")); test.x})
is what works for me.
Thank you.
Regards,
Ray Brownrigg
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Thu 01 Feb 2001 - 16:14:15 EST