# styler: off
census <- tribble(
~dbh, ~status,
0, "A",
50, "A",
100, "A",
150, "A",
NA, "M",
NA, "D",
NA, NA
)
# styler: on
# <=
pick_dbh_max(census, 100)
pick_dbh_max(census, 100, na.rm = TRUE)
# >=
pick_dbh_min(census, 100)
pick_dbh_min(census, 100, na.rm = TRUE)
# <
pick_dbh_under(census, 100)
pick_dbh_under(census, 100, na.rm = TRUE)
# >
pick_dbh_over(census, 100)
pick_dbh_over(census, 100, na.rm = TRUE)
# Same, but `subset()` does not let you keep NAs.
subset(census, dbh > 100)
# ==
pick_status(census, "A")
pick_status(census, "A", na.rm = TRUE)
# !=
drop_status(census, "D")
drop_status(census, "D", na.rm = TRUE)
# Compose
pick_dbh_over(
drop_status(census, "D", na.rm = TRUE),
100
)
# More readable as a pipiline
census %>%
drop_status("D", na.rm = TRUE) %>%
pick_dbh_over(100)
# Also works with ViewFullTables
# styler: off
vft <- tribble(
~DBH, ~Status,
0, "alive",
50, "alive",
100, "alive",
150, "alive",
NA, "missing",
NA, "dead",
NA, NA
)
# styler: on
pick_dbh_max(vft, 100)
pick_status(vft, "alive", na.rm = TRUE)
Run the code above in your browser using DataLab