I am developing a Shiny app, which generates folders and subfolders for each user and each of their experiments.
I wish to ensure that neither the user nor experiment names contain any illegal characters.
I define a character vector with every illegal character that I know of, however, there is a chance of human errors. Is there a more precise way of doing this?
dir <- "~/home/my_app_data"
usr <- "john"
exp <- "explosion`s"
path <- paste(dir, usr, exp, sep = "/")
illegal <- c(" ", ",", "`")
if (any(illegal %in% (strsplit(x = path, split = "") %>% unlist))) {
stop( "Illegal characters used")
} else {
dir.create(path, recursive = T)
}