powered by
Extracts the only distinct value from an atomic vector or throws an informative error if no values or multiple distinct values.
only(x, na_rm = FALSE)
The only distinct value from a vector otherwise throws an error.
An atomic vector.
A flag indicating whether to exclude missing values.
only() is useful when summarizing a vector by group while checking the assumption that it is constant within the group.
only()
dplyr::first()
only(c(1, 1)) only(c(NA, NA)) only(c(1, 1, NA), na_rm = TRUE) try(only(character(0))) try(only(c(1, NA))) try(only(c(1, 2)))
Run the code above in your browser using DataLab