summaryStats {CALIBERdatamanage} | R Documentation |
These functions are designed to be used when creating summary tables. There is an option to produce LaTeX output (math mode).
nmissing(x, ...) percent(logicalvector, dp = 1, latex = (getOption("xtable.type") == "latex")) npercent(logicalvector, ...) percentConf(logicalvector, dp = 1, ...) meansd(x, ...)
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
# 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)"