Hello R masters,

This request is being made after searching through archive mailing list.

I have a "many" table in a medical application where each injury a person 
suffers is recorded as a separate row.  In my toy example below it means 
respondent #1 had three injuries and so on.

If x2 equal 2 then I want to delete all the rows for that person from the 
dataframe--see Before and After below.  I have thought about using match to 
first identify the IDs that have a 2 in x2 and then in a second step delete all 
rows that have matching IDs with this subset, but I have not been able to get 
it to work.  Any help would be much appreciated.


Before
x1 <- c(1,1,1,2,2,3,3,3)
x2 <- c(2,3,3,1,1,4,4,2)
x3 <- data.frame(x1,x2)
> x3
  x1 x2
1  1  2
2  1  3
3  1  3
4  2  1
5  2  1
6  3  4
7  3  4
8  3  2

After
  x1 x2
1  2  1
2  2  1

R 2.3.0
Windows XP

Thanks!
Greg Blevins
The Market Solutions Group


        [[alternative HTML version deleted]]

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to