3 \alias{sanitize.numbers}
\r
4 \alias{sanitize.final}
\r
7 Sanitization Functions
\r
10 Functions for sanitizing elements of a table produced by
\r
11 \pkg{xtable}. Used for dealing with characters which have special
\r
12 meaning in the output format.
\r
16 sanitize.numbers(str, type, math.style.negative)
\r
17 sanitize.final(str, type)
\r
21 \item{str}{A character object to be sanitized.}
\r
22 \item{type}{Type of table to produce. Possible values for \code{type}
\r
23 are \code{"latex"} or \code{"html"}.
\r
24 Default value is \code{"latex"}.}
\r
25 \item{math.style.negative}{In a LaTeX table, if \code{TRUE}, then use
\r
26 $-$ for the negative sign (as was the behavior prior to version 1.5-3).
\r
27 Default value is \code{FALSE}.}
\r
31 If \code{type} is \code{"latex"}, \code{sanitize()} will replace
\r
32 special characters such as \verb{&} and the like by strings which will
\r
33 reproduce the actual character, e.g. \verb{&} is replaced by
\r
36 If \code{type} is \code{"html"}, \code{sanitize()} will replace
\r
37 special characters such as \verb{<} and the like by strings which will
\r
38 reproduce the actual character, e.g. \verb{<} is replaced by
\r
41 When \code{math.style.negative} is \code{TRUE}, and \code{type} is
\r
42 \code{"latex"}, $-$ is used for the negative sign rather than a
\r
43 simple hyphen (-). No effect when \code{type} is \code{"html"}.
\r
45 When \code{type} is \code{"latex"} \code{sanitize.final} has no
\r
46 effect. When \code{type} is \code{"html"}, multiple spaces are
\r
47 replaced by a single space and occurrences of \code{' align="left"'}
\r
51 Returns the sanitized character object.
\r
55 Code was extracted from \code{print.xtable()}, in version 1.8.0 of
\r
56 \pkg{xtable}. Various authors contributed the original code: Jonathan
\r
57 Swinton <jonathan@swintons.net>, Uwe Ligges
\r
58 <ligges@statistik.uni-dortmund.de>, and probably David B. Dahl
\r
59 <dahl@stat.byu.edu>.
\r
64 insane <- c("&",">", ">","_","\%","$","\\\\","#","^","~","{","}")
\r
65 names(insane) <- c("Ampersand","Greater than","Less than",
\r
66 "Underscore","Percent","Dollar",
\r
67 "Backslash","Hash","Caret","Tilde",
\r
68 "Left brace","Right brace")
\r
69 sanitize(insane, type = "latex")
\r
70 insane <- c("&",">","<")
\r
71 names(insane) <- c("Ampersand","Greater than","Less than")
\r
72 sanitize(insane, type = "html")
\r
74 sanitize.numbers(x, "latex", TRUE)
\r
75 sanitize.numbers(x, "html", TRUE)
\r