Reputation: 1
I have a data frame like this:
df
Name score1 score2
tim 5 man
poe 10 girl
rob -3 man
koi -2 girl
jan 0 girl
I wanna filter the column "score1" with values bigger than 0, but only for names that are "man" in score2.
My idea is to use dplyr
, and do something like
df %>% group_by(score2) %>% filter(score1 > 0)
is this way correct? thank you, regards
Upvotes: 0
Views: 86
Reputation: 4425
Try this
library(dplyr)
df %>% filter( score1 > 0 & score2 == "man")
Upvotes: 1