View source: R/formatted.signif.r
formatted.signif | R Documentation |
Forced length significant digits
formatted.signif(x, digits = 3, latex = FALSE, align.dot = FALSE)
x |
a vector of values to be processed into significant digits format |
digits |
single value specifying the number of significant digits |
latex |
whether to convert scientific notation to latex equivalent (e -> *10^) |
align.dot |
whether to decimal-align the result |
A formatted character vector containing x
in with significant digits
format
signif
library(xtable)
formatted.signif(c(5,4.99, 4.99999,5.0000001,5001),4)
numvec = c(5,4.99, 4.99999,5.0000001,5001, 0.00005,101,39.9)
print(
xtable(
data.frame(original = numvec
,latex.TRUE = formatted.signif(numvec,3, TRUE,FALSE)
,align.TRUE = formatted.signif(numvec,3, FALSE,TRUE)
,all.TRUE = formatted.signif(numvec,3, TRUE,TRUE)
)
)
, booktabs = TRUE
, sanitize.text.function = identity
)
# now take this to a LaTeX compiler!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.