View source: R/SummaryStatsBy.R
SummaryStatsBy | R Documentation |
Splits the data by two variables, computing relevant statistics for each variable.
SummaryStatsBy(
data,
by1,
by2,
var.names,
stats = c("mean", "sd", "median", "IQR", "range", "missing"),
digits = 3,
format = c("raw", "pandoc", "html", "long")
)
data |
The |
by1 |
character string of splitting variable 1 |
by2 |
character string of splitting variable 2 |
var.names |
character vector of variables to compute statistics for |
stats |
statistics to compute for continuous variables |
digits |
number of digits to round to |
format |
format to return the table in. Either "raw", "pandoc" (for Word and PDF), "html", or "long" format for graphing and data manipulation using raw values. |
The data
is split by two variables, by1
and by2
, and
statistics are computed for continuous variables. Statistics currently
supported include mean, sd, median, IQR, range
, and the number of
missing cases. For factor variables, the counts, column and row percentages
are shown for each of the variable levels.
Note that marginal statistics are also shown for by1
, so the order in
which you split data
matters.
There are four print options for the output: raw
gives the output as a
character matrix, pandoc
gives a Pandoc-friendly output for Word and
PDF reports, html
gives HTML supported output, and long
is a
tidy version of raw
.
Aline Talhouk, Derek Chiu
mtcars$vs <- as.factor(mtcars$vs); mtcars$am <- as.factor(mtcars$am)
SummaryStatsBy(mtcars, by1 = "cyl", by2 = "gear", var.names = c("mpg", "vs",
"qsec", "am"))
SummaryStatsBy(mtcars, by1 = "cyl", by2 = "gear", var.names = c("vs",
"qsec"))
SummaryStatsBy(mtcars, by1 = "cyl", by2 = "gear", var.names = c("mpg"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.