Description Usage Arguments Details Value Author(s) Examples

Functions for sanitizing elements of a table produced by xtable. Used for dealing with characters which have special meaning in the output format.

1 2 3 4 5 6 |

`str` |
A character object to be sanitized. |

`type` |
Type of table to produce. Possible values for |

`math.style.negative` |
In a LaTeX table, if |

`math.style.exponents` |
In a LaTeX table, if |

`...` |
Additional arguments. Character strings or character vectors. |

If `type`

is `"latex"`

, `sanitize()`

will replace
special characters such as `&`

and the like by strings which will
reproduce the actual character, e.g. `&`

is replaced by
`\&`

.

If `type`

is `"html"`

, `sanitize()`

will replace
special characters such as `<`

and the like by strings which will
reproduce the actual character, e.g. `<`

is replaced by
`<`

.

When `math.style.negative`

is `TRUE`

, and `type`

is
`"latex"`

, $-$ is used for the negative sign rather than a
simple hyphen (-). No effect when `type`

is `"html"`

.

When `type`

is `"latex"`

, and `math.style.exponents`

is `TRUE`

or `"$$"`

, then use `$5 \times 10^{5}$`

for
5e5. If `"ensuremath"`

, then use ```
\ensuremath{5 \times
10^{5}}
```

for 5e5. If `"UTF-8"`

or `"UTF-8"`

, then use UTF-8
to approximate the LaTeX typsetting for 5e5.

When `type`

is `"latex"`

`sanitize.final`

has no
effect. When `type`

is `"html"`

, multiple spaces are
replaced by a single space and occurrences of `' align="left"'`

are eliminated.

`as.is`

and `as.math`

are trivial helper functions to
disable sanitizing and to insert a some mathematics in a string
respectively.

Returns the sanitized character object.

Code was extracted from `print.xtable()`

, in version 1.8.0 of
xtable. Various authors contributed the original code: Jonathan
Swinton <jonathan@swintons.net>, Uwe Ligges
<ligges@statistik.uni-dortmund.de>, and probably David B. Dahl
<dahl@stat.byu.edu>.
`as.is`

and `as.math`

suggested and provided by Stefan
Edwards <sme@iysik.com>.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | ```
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*10^(10), "latex", TRUE, TRUE)
sanitize.numbers(x, "html", TRUE, TRUE)
as.is(insane)
as.math("x10^10", ": mathematical expression")
``` |

```
Ampersand Greater than Less than Underscore Percent
"\\&" "$>$" "$>$" "\\_" "\\%"
Dollar Backslash Hash Caret Tilde
"\\$" "$\\backslash$" "\\#" "\\verb|^|" "\\~{}"
Left brace Right brace
"\\{" "\\}"
Ampersand Greater than Less than
"&" ">" "<"
[1] "$-$0.0404140766861751" "0.636543152719045" "$-$0.334212549141633"
[4] "$-$0.441481471994549" "$-$0.812640444805861" "1.16342273363061"
[7] "0.210935105334991" "$-$1.14077057784795" "1.19715471501747"
[10] "$-$0.209588497506731"
[1] "$-$404140766.861751" "6365431527.19045" "$-$3342125491.41633"
[4] "$-$4414814719.94549" "$-$8126404448.05861" "11634227336.3061"
[7] "2109351053.34991" "$-$11407705778.4795" "11971547150.1747"
[10] "$-$2095884975.06731"
[1] -0.04041408 0.63654315 -0.33421255 -0.44148147 -0.81264044 1.16342273
[7] 0.21093511 -1.14077058 1.19715472 -0.20958850
Ampersand Greater than Less than
"&" ">" "<"
[1] "$x10^10$: mathematical expression"
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.