max_levels | R Documentation |
Given a data frame with columns specifying hierarchically-nested levels, find the maximum non-missing hierarchical level for each row.
max_levels(x, pattern, by, type = c("index", "name"))
x |
a data frame containing hierarchical columns |
pattern |
regex pattern to match the names of the hierarchical columns
in |
by |
vector giving the names of the hierarchical columns in |
type |
type of return, either "index" to return integer indices
(starting at 1) or "name" to return column names (as matched by |
Vector of indices or names corresponding to the maximum non-missing hierarchical level for each row
data(ne_ref)
# return integer indices (starting at 1)
max_levels(ne_raw, pattern = "^adm")
# return column names
max_levels(ne_raw, pattern = "^adm", type = "name")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.