R/flag_if_group.R
flag_if_group.Rd
These functions extend flag_if()
] and detect_if()
to
work by groups defined with dplyr::group_by()
.
flag_if_group(.data, name, predicate, condition = warn, msg = NULL)
detect_if_group(.data, name, predicate)
A dataframe.
String. The name of a column of the dataframe.
A predicate function, e.g. is_multiple()
.
A condition function, e.g. rlang::inform()
or
base::stop()
.
String to customize the returned message.
flag_if_group()
: A condition and its first input, invisibly.
detect_if_group()
: Logical of length 1.
Other functions to check inputs:
check_crucial_names()
,
is_multiple()
Other functions for developers:
check_crucial_names()
,
extract_insensitive()
,
is_multiple()
,
nms_try_rename()
,
rename_matches()
,
type_ensure()
tree <- tibble(CensusID = c(1, 2), treeID = c(1, 2))
detect_if_group(tree, "treeID", is_multiple)
#> [1] TRUE
flag_if_group(tree, "treeID", is_multiple)
#> Warning: treeID: Flagged values were detected.
by_censusid <- group_by(tree, CensusID)
detect_if_group(by_censusid, "treeID", is_multiple)
#> [1] FALSE
flag_if_group(by_censusid, "treeID", is_multiple)