Agustin Lobo-4 wrote:
>
> What's the most correct way of doing the equivalent to
> apply(x[,2:5],1,sum)
>
> if x is dataframe in which the only numeric fields are
> in columns 2:5 ?
> (using apply returns a character vector)
>
Could it be that you meant apply(x[,2:5],2,sum)? Not very easy to remember,
when
to use 2 or 1. Also check rowSums and colSums (note the plural forms!) that
can be MUCH faster.
Dieter
--
View this message in context:
http://www.nabble.com/Equivalent-to-apply%28x-%2C2%3A5-%2C1%2Csum%29-for-dataframe-tp20626483p20627203.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.