]> git.donarmstrong.com Git - xtable.git/blob - pkg/man/sanitize.Rd
aa4624763feb786f0426b263c27d42a123336a97
[xtable.git] / pkg / man / sanitize.Rd
1 \name{sanitize}\r
2 \alias{sanitize}\r
3 \alias{sanitize.numbers}\r
4 \alias{sanitize.final}\r
5 \r
6 \title{\r
7   Sanitization Functions\r
8 }\r
9 \description{\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
13 }\r
14 \usage{\r
15 sanitize(str, type)\r
16 sanitize.numbers(str, type, math.style.negative)\r
17 sanitize.final(str, type)\r
18 }\r
19 \r
20 \arguments{\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
28 }\r
29 \details{\r
30 \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
34   \verb{\\&}.\r
35 \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
39   \verb{&lt;}.\r
40 \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
44 \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
48   are eliminated.\r
49 }\r
50 \value{\r
51   Returns the sanitized character object.\r
52 }\r
53 \r
54 \author{\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
60 }\r
61 \r
62 \examples{\r
63 \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
73 x <- rnorm(10)\r
74 sanitize.numbers(x, "latex", TRUE)\r
75 sanitize.numbers(x, "html", TRUE)\r
76 }\r
77 \r
78 \keyword{print }\r