Created
June 8, 2021 01:09
-
-
Save dreidpath/acaa43756ccc48bc089f941a8bd1ff2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' In a dataframe, find all variable names that match var_pattern | |
#' | |
#' @param var_pattern a character string ("pattern" to match) | |
#' @param dframe a dataframe | |
#' | |
#' @return all variable names in the dataframe that match var_pattern | |
#' @export | |
#' | |
#' @examples | |
#' find_var(iris, "idth") | |
#' find_var(iris, ".") | |
#' | |
find_varname <- function(dframe, var_name){ | |
names(dframe)[grepl(var_name, names(dframe))] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment