You could do something like
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)