Examples for 'xtable::sanitize'


Sanitization Functions

Aliases: sanitize sanitize.numbers sanitize.final as.is as.math

Keywords: print

### ** 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")
      Ampersand    Greater than       Less than      Underscore         Percent 
          "\\&"           "$>$"           "$>$"           "\\_"           "\\%" 
         Dollar       Backslash            Hash           Caret           Tilde 
          "\\$" "$\\backslash$"           "\\#"     "\\verb|^|"         "\\~{}" 
     Left brace     Right brace 
          "\\{"           "\\}" 
insane <- c("&",">","<")
names(insane) <- c("Ampersand","Greater than","Less than")
sanitize(insane, type = "html")
   Ampersand Greater than    Less than 
     "&amp;"       "&gt;"       "&lt;" 
x <- rnorm(10)
sanitize.numbers(x, "latex", TRUE)
 [1] "0.267878389818368"    "$-$1.64446741467414"  "0.340693638296023"   
 [4] "0.652353284196503"    "$-$1.48452430714284"  "1.93300267842651"    
 [7] "0.0495967790815352"   "$-$0.980644993584116" "0.506548197475807"   
[10] "0.390576600121944"   
sanitize.numbers(x*10^(10), "latex", TRUE, TRUE)
 [1] "2678783898.18368"    "$-$16444674146.7414" "3406936382.96023"   
 [4] "6523532841.96502"    "$-$14845243071.4284" "19330026784.265"    
 [7] "495967790.815352"    "$-$9806449935.84116" "5065481974.75807"   
[10] "3905766001.21944"   
sanitize.numbers(x, "html", TRUE, TRUE)
 [1]  0.26787839 -1.64446741  0.34069364  0.65235328 -1.48452431  1.93300268
 [7]  0.04959678 -0.98064499  0.50654820  0.39057660
as.is(insane)
   Ampersand Greater than    Less than 
         "&"          ">"          "<" 
as.math("x10^10", ": mathematical expression")
[1] "$x10^10$: mathematical expression"

[Package xtable version 1.8-4 Index]