Hi all,
I'm trying to write a function that will recode a column using str_detect. I have 59 elementary schools that each have a unique ID number, however some of the extracts have only the school name. These are often inconsistent with capitalization, short forms (PS/P.S./Public School) so I'd like to recode using str_detect. Example:
x <- c("Fulton Elementary", "Warner Community School", "Bashford PS")
x <- tolower(x)
dplyr::recode (x,
"fulton elementary" = "1234",
"warner community school" = "5678",
"bashford ps" = "91011")
Returns:
[1] "1234" "5678" "91011"
What I would like is something like:
x <- dplyr::recode (x, str_detect (x, "fult") = "1234")