[R] Listing function
Petr Klasterecky
klaster at karlin.mff.cuni.cz
Mon Mar 26 16:08:47 CEST 2007
Use c() to extend your list creating a list of lists:
Lst = list(name="Fred", wife="Mary", no.children=3, cild.ages=c(4,7,9))
Lst <- c(list(Lst), list(list(name="Barney", wife="Liz", no.children=2,
cild.ages=c(3,5))))
You can give names to the components:
Lst <- c(Fred=list(Lst), Barney=list(list(name="Barney", wife="Liz",
no.children=2, cild.ages=c(3,5))))
See ?c for more information. You can also use a data.frame if this looks
too messy.
Petr
Schmitt, Corinna napsal(a):
> Hallo,
>
> I build a list by the following way:
>
> Lst = list(name="Fred", wife="Mary", no.children=3, cild.ages=c(4,7,9))
>
> I know how I can extract the information one by one. But now I want to
> add a new entry which looks like
>
> name="Barney", wife="Liz", no.children=2, cild.ages=c(3,5)
>
> How can I add this information to Lst without overwriting the first
> entry?
> How can I then extract the corresponding information if I have both
> entries in Lst?
>
> Thanks for helping,
>
> Corinna
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
--
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic
More information about the R-help
mailing list