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
Try this
library(dplyr)
df %>% filter( score1 > 0 & score2 == "man")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.