Last active
March 7, 2019 21:33
-
-
Save vikjam/0538ea33795c5059ecc680fed52a2f1c to your computer and use it in GitHub Desktop.
Replicate the the lookfor command in Stata
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
# 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