Hello all, I've tried to solve this for weeks and posted to other forums with little success- I'd appreciate any help from anyone.
I have survey data grouped by facility and area (area is a collection of facilities). Questions are q1-q10. For each facility, I need to subset each item into the facility's responses, and the facility's area responses excluding the facility. This might illustrate it better: Area Facility Q1... Q10 1 1 2 1 2 3 1 3 1 2 4 4 2 5 5 2 6 2 A<- Select Q1 for all Area=1 and Facility!=1; B<- Select Q1 for all Facility=1; <do something with A and B> A<- Select Q1 for all Area=1 and Facility!=2; B<- Select Q1 for all Facility=2; <do something with A and B> A<- Select Q1 for all Area=1 and Facility!=3; B<- Select Q1 for all Facility=3; <do something with A and B> ... A<- Select Q10 for all Area=2 and Facility!=6; B<- Select Q10 for all Facility=6; <do something with A and B> I know how to write the code to manually pull each subset, but I have a lot of facilities and areas that get renamed from year to year so I need to "vectorize" my code so each subset doesn't have to be explicitly called by area or facility name. Again, I would be incredibly appreciative of any help. I'm at a dead-end. Ryan ______________________________________________ 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.