Skip to content
Prev 244371 / 398506 Next

sd() for numeric row entries

Jim -
    Suppose the data frame is named "df".  Then

df$std_dev = apply(df,1,sd,na.rm=TRUE)

will do what you want, although it will generate
some warning messages due to the first column.

df$sd_dev = apply(df[,sapply(df,is.numeric)],1,sd)

does the same, but won't produce warnings.

 					- Phil Spector
 					 Statistical Computing Facility
 					 Department of Statistics
 					 UC Berkeley
 					 spector at stat.berkeley.edu
On Wed, 8 Dec 2010, Jim Moon wrote: