Re: [R] Help with IF command strings

2013-07-12 Thread arun
Hi, Regarding the 2nd issue of mean=3.8 being "too high", could you explain it. #Using the same example:  dat1$V21[dat1$V2==1|dat1$V2==0] #[1]  6  2  1 10  0  (6+2+1+10+0)/5 #[1] 3.8  mean(dat1$V21[dat1$V2==1|dat1$V2==0]) #[1] 3.8 About missing data: set.seed(55) dat2<- as.data.frame(matrix(sample

Re: [R] Help with IF command strings

2013-07-12 Thread arun
Hi, Not sure I understand your question. Suppose `data1` is your real data, but if the column names are different, change "V21", "V2" by those in the real data. Based on your initial post, the column names seemed to be the same. mean(data1$V21[data1$V2==1|data1$V2==0]) A.K.  What values woul

Re: [R] Help with IF command strings

2013-07-11 Thread arun
HI, Try this: set.seed(485) dat1<- as.data.frame(matrix(sample(0:10,26*10,replace=TRUE),ncol=26)) mean(dat1$V21[dat1$V2==1|dat1$V2==0]) #[1] 3.8 #or with(dat1,mean(V21[V2==1|V2==0])) #[1] 3.8 A.K. I have data in 26 columns, I'm trying to get a mean for column 21 only for the participants that