Monaly Mistry
2014-May-22 14:13 UTC
[R] subsetting to exclude different values for each subject in study
Hi, I've written a code to determine the difference in score for a single subject and its non-neighbours o<-(ao[,c(13,5)]) ##this is the table with the relevant information o<-na.omit(o) ##omitted data with NA o<-o[!o$NestkastNummer %in% c(176,140,162,713),] ##removed neighbours XO[7,1]<-abs((XO[1,"176"]-(mean(o[,"COR_LOC"])))) #difference between that individual and average non-neighbours scores Since each subject has a different number of non-neighbours I was wondering if there is an efficient way of writing the code, instead of writing the same code again and again (76 subjects) for each subject and its non-neighbours. Best, Monaly. [[alternative HTML version deleted]]