[R] Deleting rows that contain certain characters...or deleting ANOVA factors
Crosby, Jacy R
Jacy.R.Crosby at uth.tmc.edu
Wed Apr 22 18:44:09 CEST 2009
I'm hoping there's an easier way to do this...
I have a large matrix which looks like this (data=REG, rownames are the Pat1, Pat2,...):
L1 L2 L3 Phen1 Phen2 Phen3
Pat1 AA TT A? 143 143 143
Pat2 AT ?A AT 256 256 NA
Pat3 TA ?? TA 212 212 212
Pat4 TT ?T AA NA 220 220
Pat5 T? A? AT 98 98 98
Pat6 ?A AA TA 113 113 113
Pat7 ?? ?? TT 178 178 178
Pat8 ?T ?T T? 200 NA 200
Pat9 A? A? A? 120 120 120
Pat10 AA AA T? 230 230 230
I'm performing an ANOVA:
for(i in 1:3){
for(j in 1:3){
x<-summary(aov(REG[,3+j]~REG[,i], data=REG, na.act=na.exclude))[[1]][,5] #summary()[[1]][,5] to extract p-value
aov1[i,j]<-x[-2] #removes the second element of pvalue...an NA
}
}
This works fine and returns a p-value for each Phen~L model. However, I'd like to exclude cases where there is a '?' in L. I do not need these for the analysis.
i.e. I'd like to have aov(Phen1~L1) use only Pat1-Pat4,and Pat 10.
Similarly, aov(Phen1~L2) should use Pat1, 6, and 10.
Etc.
Is this something I can do in the aov function, or do I need to modify my dataset before running aov? In either case, I need ideas...
More information about the R-help
mailing list