Вы можете сделать это sh, сгруппировавшись по location.id
и отфильтровав на сумму Fruit_total
:
library(tidyverse)
df %>%
group_by(location.ID) %>%
filter(sum(Fruit_total) != 0)
Выход:
# A tibble: 22 x 5
# Groups: location.ID [11]
location.ID Year plant treatment Fruit_total
<dbl> <dbl> <chr> <chr> <dbl>
1 7 2019 Anaheim.Peppers.Count Control 23
2 9 2019 Anaheim.Peppers.Count Control 3
3 15 2019 Anaheim.Peppers.Count Control 0
4 23 2019 Anaheim.Peppers.Count Control 1
5 38 2019 Anaheim.Peppers.Count Control 8
6 41 2019 Anaheim.Peppers.Count Control 1
7 42 2019 Anaheim.Peppers.Count Control 12
8 43 2019 Anaheim.Peppers.Count Control 7
9 45 2019 Anaheim.Peppers.Count Control 5
10 49 2019 Anaheim.Peppers.Count Control 13
# ... with 12 more rows