R/sanitise_percent.R

Defines functions sanitise_percent

Documented in sanitise_percent

#' Sanitise function for use with `print.xtable`
#'
#' @description Takes a string of text and sanitises only the use of "%" for
#'              use with latex
#'
#' @param str String of text
#'
#' @examples
#'     str <- "\\multirow{2}{4cm}{75%}"
#'     sanitise_percent(str)
#'
#' @export
sanitise_percent <- function(str) {
  result <- gsub("%", "\\%", str, fixed = TRUE)

  return(result)
}
EstherHerbert/Useful.functions documentation built on Jan. 31, 2025, 10:41 a.m.