Newer
Older
#' Wrapper for `system.file` for this package
#'
#' @inherit base::system.file
#'
#' @export
#'
#' @examples
#' pkg_sys()
#'
pkg_sys <- function(
...,
package = utils::packageName(),
lib.loc = NULL,
mustWork = FALSE
) {
system.file(
...,
package = package,
lib.loc = lib.loc,
mustWork = mustWork
)
}
#' Purge a string from all accents and special characters
#'
#' @param x the [character] string to purge
#' @param replacement the [character] to use for replacing special characters
#'
#' @return A purged [character] string
#' @export
#'
#' @examples
#' purge_string("Là chaîne pl€ine dé &#/* $péciaux", "_")
#'
purge_string <- function(x, replacement = " ") {
iconv(gsub(paste0(replacement, "+"), replacement,
gsub("&|=|-|:|\\.|'|\\/|<|>|e0|e9|e8|e7|e6|_|\\(|\\)|\"|\\*|#|€|\\$|\\%",
replacement,
enc2utf8(x))),
from = "UTF-8",
to = "ASCII//TRANSLIT")
}