Description Usage Arguments Value Author(s) See Also Examples
These functions are designed to be used when creating summary tables. There is an option to produce LaTeX output (math mode).
1 2 3 4 5 6 |
x |
a numeric vector (missing values are ignored) |
logicalvector |
a logical vector (missing values are ignored) |
dp |
number of decimal places |
latex |
TRUE for LaTeX output (math mode), FALSE, NULL or logical(0) for plain text output |
... |
other arguments to pass to |
a character vector containing the formatted summary statistic. percentConf
prints the percentage and a confidence interval using the binomial distribution, without percentage signs.
Anoop Shah
formatnum
, formatp
, formathr
, formatci
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # Number and % missing
nmissing(c(1, 2, 3, NA, NA), latex = FALSE)
# "2 (40.0%)"
nmissing(c(1, 2, 3, NA, NA), latex = TRUE)
# "2 (40.0\%)"
# Percentage
percent(c(TRUE, TRUE, FALSE, NA), latex = FALSE)
# "66.7%"
percent(c(TRUE, TRUE, FALSE, NA), latex = TRUE)
# "66.7\%"
# Number and percentage
npercent(c(TRUE, TRUE, FALSE, NA), latex = FALSE)
# "2 (66.7%)"
npercent(c(TRUE, TRUE, FALSE, NA), latex = TRUE)
# "2 (66.7\%)"
# Percentage with 95% confidence interval
percentConf(c(TRUE, TRUE, FALSE, NA), latex = FALSE)
# "66.7 (9.43, 99.2)"
percentConf(c(TRUE, TRUE, FALSE, NA), latex = TRUE)
# "$66.7$ ($9.43$, $99.2$)"
# Mean and standard deviation
meansd(1:100, latex = FALSE)
# "50.5 (29)"
meansd(1:100, latex = TRUE)
# "$50.5$ ($29$)"
meansd(1:100, dp = 5, latex = FALSE)
# "50.50000 (29.01149)"
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.