[R] safe data.restore

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Tue Aug 14 17:33:19 CEST 2001


"Martin Henry H. Stevens" <hstevens at muohio.edu> writes:

> (R 1.3.0, ESS, Emacs, Windows)
> I would like to import a set of objects exported from S+ v. 6, beta2 using
> data.dump, but I want to make sure that it does not overwrite current
> objects I am using in R. How would I route the output of data.restore() to
> ensure the safety of my current objects?

How about

sapply(local({
  data.restore("dumpdata", env=environment());
  ls()
}), exists)

(and maybe wrap an any() around that if there are many objects)

Or,

e <- new.env()
data.restore("dumpdata", env=e)
sapply(ls(env=e), exists)
rm(e)


(provided you have no variable called "e" of course...)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list