[R] question

David Winsemius dwinsemius at comcast.net
Wed Feb 15 15:16:05 CET 2012


On Feb 15, 2012, at 7:19 AM, R. Michael Weylandt wrote:

> Sorry about that -- forgot the case where you might only have a
> certain entry once: try this,
>
> sapply(split(GS, rownames(GS)), function(x) colSums(as.matrix(x)))
>
> or
>
> sapply(split(GS, rownames(GS)), function(x) if(is.matrix(x))  
> colSums(x) else x)
>
> I'm not sure if there's a way to force split to give you matrix
> elements back but it would be nice.

The help(split) page says there is a 'drop' parameter. That would have  
been what I tried first.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list