library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
set.seed(2021)
df <- data.frame(
month = sample(c("apr","may","jun"),40,replace=T),
value = rnorm(40)
)
df1 <- df %>%
group_by(month) %>%
mutate (pc =percent_rank(value)) %>%
filter( month != "may" | pc >= 0.5)
Created on 2021-09-14 by the reprex package (v2.0.0)
With the code in this thread, it works for me and it should also work for you.
If you want us to help you, show us your code. E.g. by using a reprex with a limited number of input rows.