Text data often needs a machine-friendly version. Base R string functions can normalize names.

Program

Play the script to lowercase a name, replace spaces, and add a file extension.

string_cleanup.R
name <- "Ada Lovelace"
slug <- tolower(gsub(" ", "_", name))
label <- paste0(slug, ".txt")
cat(label, "\n", sep = "")
gsub `gsub(" ", "_", name)` replaces every space with an underscore.
tolower `tolower` converts text to lowercase.
paste0 `paste0` joins strings without inserting spaces.