[R] Exporting a list of lists
Roland Rau
roland.rproject at gmail.com
Mon Aug 11 22:26:23 CEST 2008
Hi Kevin,
check
?dump
set.seed(1234)
list1 <- list(a1=rnorm(100), a2=rnorm(10))
list2 <- list(a1=rnorm(50), a2=rnorm(25))
mylist <- list(top1=list1, top2=list2)
dump(list="mylist", file="mydumpedlist.r")
rm(mylist)
# please note that you have to quote the name
# of the object(s) you want to dump!
source("mydumpedlist.r")
ls()
I hope this helps,
Roland
rkevinburton at charter.net wrote:
> I have a list
>
> List(Sku=" ", Shape=1, Scale=3, DayOfYear=daylist)
> Note: picture daylist as c(2,3,4,3) it is a list with variable length.
>
> Then I have a list of lists
>
> al <- c(al, List(List(Sku=" ", Shape=1, Scale=3, DayOfYear=daylist))
> Note: same comment on daylist as above.
>
> So far this creates a list of lists just how I want it. If I do al[1] I get each member and the variable length list 'daylist'.
>
> Now I want to export this list of lists:
>
> write.table(mlist, "SkuInfo.dat", row.names = FALSE, sep=",")
>
> But I get an error that the list lengths are not equal. The only member of this list that has a variable length would be DayOfYear
>
> How can I output this list of lists when each element list contains a variable length list?
>
> Thank you.
>
> Kevin
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list