[R] calculate sd for each row on some columns of a dataframe

Albert Vilella avilella at gmail.com
Thu Feb 28 12:27:51 CET 2008


Hi,

I've got a dataframe like this:

df = data.frame(a=rnorm(100,1),b=rnorm(100,10),c=rnorm(100,100),d=rnorm(100,-100))

and I want to calculate sd1 for (a,b,c) for each entry, and sd2 for
(b,c,d) for each entry.

I don't seem to find the answer using aggregate or apply,

How can I do this?

Thanks in advance,

Cheers,

    Albert.



More information about the R-help mailing list