r - Selecting & grouping dual-category data from a data frame -
I really need help with facing a problem. I have a data set that looks like this. .
Name Sex Total Anna F10 Jamie M2 Jamie F7 Mike M13 Sam F6 Sam M3 Structure (List (name = c ("Anna", "Jamie", "Jamie "M", "Sam", "Sam"), Sex = C ("F", "M", "F", "M", "F", "M"), Total = C (10 L , Name = C ("name", "gender", "total"), class = "data.frame", line name = 2, 7L, 13L, 6L, 3L) (NA, -6L))
Whatever I have to do, get the name, which are both men and women names, so the results will be shown ..
But I'm really stumped on how to get in touch.
d
:
In this way I can understand this Get the vector by the name of the data d
pre> #, which are used by both M and F. Name & lt; # Intersect (d $ name [d $ gender == 'm'], d $ name [d $ sex == 'f']) # Use duplicate names to filter data [d $ name %% dual In .names,]
Comments
Post a Comment