#' Remove non-alphanumeric and punctuation characters from strings '
#'
#' A wrapper for gsub that substitutes non-alphanumeric and punctuation
#' characters by "_". Initially idealized for generating filenames without
#' reserved characters.
#'
#' @param x the string to process.
#' @param pattern see ?gsub.
#' @param replacement see ?gsub.
#' @keywords replace, substitute
#' @export
#' @examples
#' substitute_non_alphanumeric_and_punctuation("1 !#$%* 11 ;'. R Tutorial")
substitute_non_alphanumeric_and_punctuation <-
function(x, pattern = "[^A-Za-z0-9,;._-]", replacement = "_") {
gsub(pattern,
replacement,
x)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.