On Jul 27, 2011, at 6:27 AM, christiaan pauw wrote:
Hi Everybody
I need to "transport" some data and results to use another application
(Sweave via LyX - where debugging is very difficult) in order to
build a
report.
Is it possible to store a collection of variables of different types
(like
named integers, matricies, data frames and two lists) all in one
list and
save it and then simply load it again later and "unpack" the
variables.
The usual method is to use the 'save' function and then restore or
recover objects with the 'load' function.
You could I suppose add an additional (needless) layer of making a
list , saving, loading, and then "assign'-ing values to 'names' of
that list.
--
David.
Thanks is advance
Christiaan
Please see the sample code below.
# Create variables of different types
x=expand.grid(1:4,letters[1:4])
y=matrix(1:1000,ncol=20)
z=list(a=1,b=2:20,c=matrix(1:50,ncol=5))
result.one=1
names(result.one)="first result"
result.two=2
names(result.one)="second result"
# Put them all in list
allvars=list(x,y,z,result.one,result.two)
names(allvars)=c("x","y","z","result.one","result.two")
ls()
[1] "allvars" "result.one" "result.two" "x" "y"
"z"
# Save it
save(allvars,file="allvars.Rda")
# Now remove it with rm(allvars) and load it again :
load("allvars.Rda")
What I need here is the magic function that will 'unpack" the list
and give
the same results to ls()
ls()
[[alternative HTML version deleted]]
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.