View source: R/small_helpers.R
| inverse | R Documentation |
If you have stored variable names inside a character vector, this function gives you the inverse variable name vector.
inverse(data_frame, var_names)
data_frame |
The data frame from which to take the variable names. |
var_names |
A character vector of variable names. |
Returns the inverse vector of variable names compared to the given vector.
# Example data frame
my_data <- dummy_data(1000)
# Get variable names
var_names <- c("year", "age", "sex")
other_names <- my_data |> inverse(var_names)
# Can also be used to just get all variable names
all_names <- my_data |> inverse(NULL)
all_names <- my_data |> inverse(character(0))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.