\name{sanitize} \alias{sanitize} \alias{sanitize.numbers} \alias{sanitize.final} \title{ Sanitization Functions } \description{ Functions for sanitizing elements of a table produced by \pkg{xtable}. Used for dealing with characters which have special meaning in the output format. } \usage{ sanitize(str, type) sanitize.numbers(str, type, math.style.negative) sanitize.final(str, type) } \arguments{ \item{str}{A character object to be sanitized.} \item{type}{Type of table to produce. Possible values for \code{type} are \code{"latex"} or \code{"html"}. Default value is \code{"latex"}.} \item{math.style.negative}{In a LaTeX table, if \code{TRUE}, then use $-$ for the negative sign (as was the behavior prior to version 1.5-3). Default value is \code{FALSE}.} } \details{ If \code{type} is \code{"latex"}, \code{sanitize()} will replace special characters such as \verb{&} and the like by strings which will reproduce the actual character, e.g. \verb{&} is replaced by \verb{\\&}. If \code{type} is \code{"html"}, \code{sanitize()} will replace special characters such as \verb{<} and the like by strings which will reproduce the actual character, e.g. \verb{<} is replaced by \verb{<}. When \code{math.style.negative} is \code{TRUE}, and \code{type} is \code{"latex"}, $-$ is used for the negative sign rather than a simple hyphen (-). No effect when \code{type} is \code{"html"}. When \code{type} is \code{"latex"} \code{sanitize.final} has no effect. When \code{type} is \code{"html"}, multiple spaces are replaced by a single space and occurrences of \code{' align="left"'} are eliminated. } \value{ Returns the sanitized character object. } \author{ Code was extracted from \code{print.xtable()}, in version 1.8.0 of \pkg{xtable}. Various authors contributed the original code: Jonathan Swinton , Uwe Ligges , and probably David B. Dahl . } \examples{ insane <- c("&",">", ">","_","\%","$","\\\\","#","^","~","{","}") names(insane) <- c("Ampersand","Greater than","Less than", "Underscore","Percent","Dollar", "Backslash","Hash","Caret","Tilde", "Left brace","Right brace") sanitize(insane, type = "latex") insane <- c("&",">","<") names(insane) <- c("Ampersand","Greater than","Less than") sanitize(insane, type = "html") x <- rnorm(10) sanitize.numbers(x, "latex", TRUE) sanitize.numbers(x, "html", TRUE) } \keyword{print }