Re: [R] Smart way to sum a column in a matrix across all members in a list

2009-08-11 Thread Henrique Dallazuanna
Try this: sum(sapply(l, '[[', 'b')) On Tue, Aug 11, 2009 at 11:05 PM, R_help Help wrote: > Hi, > > I have a list that contains about 100 elements. Each element contains > the following matrix structure > > a b > 1 1 4 > 2 2 5 > 3 3 6 > > I'd like to sum column b across all elements. I'm thin

[R] Smart way to sum a column in a matrix across all members in a list

2009-08-11 Thread R_help Help
Hi, I have a list that contains about 100 elements. Each element contains the following matrix structure a b 1 1 4 2 2 5 3 3 6 I'd like to sum column b across all elements. I'm thinking of using lapply or sapply but cannot get it to work. Any help would be really appreciated. Thank you. adsch