[S] List indexing question?

Gunter, Bert (bert_gunter@merck.com)
Tue, 18 Aug 1998 17:45:42 -0400

To all:

Suppose I have a long list each of whose components is a list with a fixed
structure. e.g.., a list of the form :
mylist=list(list.1=list(A1,B1), list.2=list(A2,B2), list.3=list(A3,B3)
...and so forth)

Such lists are commonly obtained from the apply() family of functions. For
simplicity in this example, assume that A1,A2, ... are just numbers but that
B1, B2, B3, ... are numeric vectors of possibly different lengths.

I would like to form a numeric vector with all the A's only. One way to do
this is:

unlist(lapply(mylist, FUN=function(x) x[ [1] ] ))

but this seems rather clumsy to me. Is there some straightforward method of
list subscripting that allows me to do the same thing? Please reply to me
personally and I'll summarize anything of interest.

Bert Gunter
Biometrics Research RY 70-38
Merck & Company
P.O. Box 2000
Rahway, NJ 07065-0900
Phone: (732) 594-7765 Fax: (732) 594-1565

"The business of the statistician is to catalyze the scientific learning
process." -- George E.P. Box

This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news