I just began to use R and I have data look like this:
Fruit Consumption Apple High Apple High Orange High Orange Low Nut Low Nut Low
I would like to remove those with mixed consumption (Orange). I first tried identifying orange with the following code before removing it out.
df1 <- df %>% group_by(Fruit) %>% filter(Consumption =="High" & Consumption =="Low")
I don't know what is wrong, but R returned zero output. I also tried changing from "AND" to "OR" but I got original data this time. Please help me!
Thanks a lot in advance!
https://stackoverflow.com/questions/65386672/remove-mixed-data-in-a-variable December 21, 2020 at 09:59AM
没有评论:
发表评论