Description Usage Arguments Details Value Author(s) Examples
Summarize variables by a categorical variable within a given data.frame. Overall and by results are presented along with simiple hypothesis tests.
1 2 3 4 5 6 7 8 9 | tableone(vars, by = NULL, data = NULL, complete = TRUE, margin = 2,
overall = TRUE, stat.con.1 = mean, stat.con.2 = sd,
tests = c("chisq.test", "t.test"), fisher = TRUE,
digits = getOption("qwraps.digits", 3), big.mark = ",")
## S3 method for class 'tableone'
print(tab1, file = "", title = "",
ctable = getOption("qwraps.tableone.ctable", TRUE), cgroup, n.cgroup,
rgroup, n.rgroup, rowname, col.just, ...)
|
vars |
characer vector of the names of the variables in data to summarize. |
by |
character name of the variable in data to sumamrize vars by |
data |
the data.frame |
complete |
logical reported for the complete data records only? If TRUE,
the dataset will be subseted via |
margin |
default to report column percentages for categorical variables, can be set to 1 for row percentages or 1:2 for overall percentages. |
overall |
logical if TRUE include a column with the summary statistics
for the whole sample in addition to the summary of the |
stat.con.1 |
function to summarize continuous variables with, default is
the |
stat.con.2 |
second function to sumamry continuous variables with,
adefault is |
tests |
a vector of length two with the statistical tests to report for 1)
categorical variables and 2) continuous variables. If set to NULL, then the
tests and associated p-values are omitted from the output. Defaults are for the
|
fisher |
logicial if TRUE and tests[1] == "chisq.test" then if
|
big.mark |
Default is a comma to separate, i.e., 1000 would be reported as 1,000. |
digits |
number of digits to round stat.con.1 and stat.con.2 |
pdigits |
number of digits to report p-values to. |
show.equal.sign |
EXPLAIN THE DETAILS MORE, FACTORS AND NUMERS ARE IMPORANT, WILL TRANSFORM CHARACTERS TO FACTORS
a list with the elements intended to be used with
Hmisc::latex
tab |
a string of formated numbers. Non-numbers are empty strings. If the p-value is less than 10^(-pdigits) the return will be '< 10^(-pdigits) |
cgrp |
a character vector for the column groups, the levels of
|
ncgrp |
a numeric vector for n.cgroup |
rgrp |
a character vector for the row groups |
rcgrp |
a numeric vector for n.cgroup |
rwnms |
a character vector of row names |
Peter DeWitt
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 | data(diamonds, package = "ggplot2")
## simple examples for the just getting the matrix for table one
## this could be used in xtable, Hmisc::latex, and likely other functions
tableone("cut", "color", diamonds[1:50, ])$tab
tableone("price", "color", diamonds[1:50, ],
tests = c("chisq.test", #' "aov"))$tab
tableone(c("cut", "price"), "color", diamonds[1:50, ],
tests = c("chisq.test", "aov"))$tab
## A LaTeX table via Hmisc::latex
tab1 <- tableone(c("cut", "price"), "color", diamonds[1:50, ],
tests = c("chisq.test", "aov"))
Hmisc::latex(tab1$tab,
file = "",
title = "Example from qwraps",
ctable = TRUE,
cgroup = tab1$cgrp,
n.cgroup = tab1$ncgrp,
colhead = NULL,
rgroup = tab1$rgrp,
n.rgroup = tab1$nrgrp,
rowname = tab1$rwnm,
caption = "Example Table 1 from the qwraps with Hmisc.",
label = "tab:tableone",
col.just = rep("r", ncol(tab1$tab)))
## A better and easier way to get the table into a LaTeX file
print(tab1)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.