I asked this on stackoverflow and I got an alternative solution, but I'm interested in understanding why str_c and str_remove_all aren't behaving the way I thought they would/giving a regex error.
iris %>% select(where(is.numeric)) %>% colnames() %>% str_c(., collapse = '","')
Output: "Sepal.Length","Sepal.Width","Petal.Length","Petal.Width" It gets me close to what I want (I don't really care about the space missing after the comma) but I can't remove the backslash afterwards with
str_remove_all because it doesn't recognize the escaped backslash
Ideal: "Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"
iris %>% select(where(is.numeric)) %>% colnames() %>% str_c(., collapse = '",') str_remove_all(., "\\")
Error in stri_replace_all_regex(string, pattern, fix_replacement(replacement), : Unrecognized backslash escape sequence in pattern. (U_REGEX_BAD_ESCAPE_SEQUENCE)