Skip to content

Instantly share code, notes, and snippets.

@vikjam
Last active March 7, 2019 21:33
Show Gist options
  • Save vikjam/0538ea33795c5059ecc680fed52a2f1c to your computer and use it in GitHub Desktop.
Save vikjam/0538ea33795c5059ecc680fed52a2f1c to your computer and use it in GitHub Desktop.
Replicate the the lookfor command in Stata
# Required packages
# dplyr
# stringr
# glue
lookfor <- function(df, pattern) {
var_i <- names(df) %>% stringr::str_detect(stringr::regex(pattern, ignore_case = TRUE))
return(names(df)[var_i])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment