Create a new variable based on pattern in the argument expr
find_diag(data, expr, colvec, ignore.case = T, perl = T)
data | input data |
---|---|
expr | regular expression describing the pattern of interest |
colvec | indices of variables of interest |
ignore.case | logical |
perl | logical |
new variable matching the pattern described in the regular expression
#> #>#>#> #>#>#> #>library(purrr) icd10cm_data150 %>% mutate(hero = find_diag(., expr = "T401.[1-4]", colvec = c(2:6))) %>% count(hero)#> # A tibble: 2 x 2 #> hero n #> <dbl> <int> #> 1 0 143 #> 2 1 7