Skip to content
Prev 199667 / 398506 Next

Using something like the "by" command, but on rows instead of columns

Some variation of the following might be want you want:

df=data.frame(sex=sample(1:2,100,replace=T),snp.1=rnorm(100),snp.15=runif(100))
df$snp.1[df$snp.1>1.0]<-NA; #put some missing values into the data
x=grep('^snp',names(df)); x #which columns that begin with 'snp'
apply(df[,x],2,summary)
#or
apply(df[,x],2,FUN=function(x)mean(x,na=T))

hth,
david
Josh B-3 wrote: