[R] question
R. Michael Weylandt
michael.weylandt at gmail.com
Wed Feb 15 15:17:55 CET 2012
But that's dropping unused factor levels, not the drop of `[`
Michael
On Wed, Feb 15, 2012 at 9:16 AM, David Winsemius <dwinsemius at comcast.net> wrote:
>
> 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