[R] Using something like the by command, but on rows instead of columns

2009-11-09 Thread Josh B
Hello R Forum users, I was hoping someone could help me with the following problem. Consider the following toy dataset: AccessionSNP_CRY2SNP_FLCPhenotype 1NAA0.783143079 2BQA0.881714811 3BQA0.886619488 4AQB0.416893034 5AQB

Re: [R] Using something like the by command, but on rows instead of columns

2009-11-09 Thread David Freedman
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.11.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