I have a data set which looks like the following (partially):
id name dummy
1 Jane 1
1 Jane 0
1 Jane 1
2 Mike 0
2 Mike 0
2 Mike 0
2 Mike 0
2 Mike 0
3 Tom 1
3 Tom 1
3 Tom 0
3 Tom 0
I'm trying to eliminate the people where ALL of the variable dummy
is 0. So for instance, Tom
and Jane
would not be eliminated because they have dummy
variable 0 or 1, but Mike
will be eliminated because he has all 0s. So I would want in the end
id name dummy
1 Jane 1
1 Jane 0
1 Jane 1
3 Tom 1
3 Tom 1
3 Tom 0
3 Tom 0
I thought about sorting the data frame according to dummy
but I can't seem to figure out how to deal with the fact that I'm only trying to eliminate the people who only has 0 values for the variable dummy
. Any suggestions would be really helpful!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…