Open theamarks opened 1 week ago
minor code update - will save several lengthy mutate if_else() statements throughout numerous scritps
mutate
if_else()
library(stringr) str_pad(c("30112", "51122", "123456"), width = 6, pad = "0")
[1] "030112" "051122" "123456"
# pad hs6 with 0s mutate(hs6 = as.character(hs6)) %>% mutate(hs6 = if_else( str_detect(hs6, "^30"), true = str_replace(hs6, pattern = "^30", replacement = "030"), if_else(str_detect(hs6, "^511"), true = str_replace(hs6, pattern = "^511", replacement = "0511"), false = hs6)))
minor code update - will save several lengthy
mutate
if_else()
statements throughout numerous scritps[1] "030112" "051122" "123456"