szhan@uoguelph.ca
2005-Dec-02 16:33 UTC
[R] how to make a sub list from a long list using the component name?
Hello, R users, I have a long list with over 20,000 elements (say foo), now I want to make a sub list of 30 elements from this list using the component names such as subname<-c( "a", "b", "d", "f", "g", "h", "o", "q",...). One way to do it is to make rest of elements in the list NULL, that is too silly. Is there another way to make the sub list? Thanks Joshua
Peter Dalgaard
2005-Dec-02 16:46 UTC
[R] how to make a sub list from a long list using the component name?
szhan at uoguelph.ca writes:> Hello, R users, > I have a long list with over 20,000 elements (say foo), now I want to make a sub > list of 30 elements from this list using the component names such as subname<-c( > "a", "b", "d", "f", "g", "h", "o", "q",...). One way to do it is to make rest of > elements in the list NULL, that is too silly. Is there another way to make the > sub list?What's wrong with foo[subname] ? -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907