library(dplyr, warn.conflicts = FALSE)
#> Warning: package 'dplyr' was built under R version 4.1.2
library(purrr)
df <- structure(list(CPE = c(42L, 264L, 470L, 316L, 9L, 114L), PERC = c(0.1132664,
0.9260718, 0.3732287, 0.7437126, 0.5819554, 0.2052649)), row.names = c(NA,
-6L), class = "data.frame")
constraints <- structure(list(CPE = c(20, 50, 100, 250), PERC = c(0.95, 0.9,
0.85, 0.8)), class = "data.frame", row.names = c(NA, -4L))
constraints
#> CPE PERC
#> 1 20 0.95
#> 2 50 0.90
#> 3 100 0.85
#> 4 250 0.80
filt <-
map2(df, constraints, outer, '>') %>%
reduce(`&`) %>%
as.data.frame %>%
reduce(`|`)
df %>%
filter(filt)
#> CPE PERC
#> 1 264 0.9260718
创建日期:2022-06-03
reprex package
(v2.0.1)