This function is primarily useful for removing any apostrophe from the filename since this will get rejected by Google Drive, but also includes features like replacing spaces with an underscore, converting to all lowercase, and adding a date prefix or suffix.

clean_filename(
  x,
  rm_apostrophe = TRUE,
  rp_space = FALSE,
  mk_lower = FALSE,
  add_date = NULL
)

Arguments

x

filepath or file name

rm_apostrophe

remove all apostrophes, default = TRUE

rp_space

replace spaces with underscore, default = FALSE

mk_lower

make lowercase, default = FALSE

add_date

add date "prefix" or "suffix"

Value

clean filename

Examples

if (FALSE) { # \dontrun{
file <- "Submission_Coted'Ivoire_data.csv"
new_file <- clean_filename(file, rm_apostrophe = TRUE, add_date = 'prefix') } # }