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]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.