Ng Stanley
2008-Apr-14 12:32 UTC
[R] Associative array and How to store a set of objects ?
Hi, Two questions: A) Assuming OB is an object, how do I store 20 of OB in a vector or list ? B) Does R has something similar associative array to Perl ? For example, %our_friends = ('best', 'Don', 'good', 'Robert', 'worst', 'Joe'); $our_friends{'cool'} = "Karen"; Thanks Stanley [[alternative HTML version deleted]]
Gabor Csardi
2008-Apr-14 12:39 UTC
[R] Associative array and How to store a set of objects ?
On Mon, Apr 14, 2008 at 08:32:55PM +0800, Ng Stanley wrote:> Hi, > > Two questions: > > A) Assuming OB is an object, how do I store 20 of OB in a vector or list ?replicate(20, OB, simplify=FALSE)> B) Does R has something similar associative array to Perl ? For example, > %our_friends = ('best', 'Don', 'good', 'Robert', 'worst', 'Joe'); > $our_friends{'cool'} = "Karen";our.friends <- list(best="Don", good="Robert", worst="Joe") our.friends[["cool"]] <- "Karen" G. PS. Concerning the second question, what about reading 'Introduction to R'?> Thanks > Stanley > > [[alternative HTML version deleted]] > > ______________________________________________ > 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.-- Csardi Gabor <csardi at rmki.kfki.hu> UNIL DGM