yat | R Documentation |
Create a table of summary statistics using a formula interface. The left-hand-side of the formula corresponds to groups to create summaries by and the right hand side consists of functions of variables to summarize.
yat(formula, data)
formula |
a For example, to summarize sepal length and sepal width overall and
by species in the |
data |
a |
A data.frame
with a first column named variable
,
a second column named categories
and subsequent columns
corresponding to the left hand side (grouping) variable(s).
This package is brand new and should be considered very preliminary.
Stephen Weigand <weigand.stephen@mayo.edu>
## Using base functions on the right hand side data(iris) yat(Species + 1 ~ # left hand side means by Species and overall median(Sepal.Length) + median(Sepal.Width) + median(Petal.Length) + median(Petal.Width), iris) ## Two different summaries of 'Sepal.Length' by species yat(Species ~ mean(Sepal.Length) + sd(Sepal.Length), iris) ## Using the 'mediqr' function in yat which provides formatted output ## and can have labels yat(Species ~ mediqr(Sepal.Length, lab = "Median length (IQR) --- cm", dig = 1) + mediqr(Sepal.Width, lab = "Median width (IQR) --- cm", dig = 1), iris) ## Numbers and percentages by group plus mean and SD for cylinders ## and horsepower by automatic (am=0) or manual (am=1) transmission data(mtcars) yat(am ~ npct(cyl, "Cylinders, n (%)") + meansd(hp, "Mean horsepower (SD)"), mtcars) ## Writing a simple custom summary to use on the right hand side minmax <- function(x, dig = 0) { paste(formatC(range(x, na.rm = TRUE), format = "f", digits = dig), collapse = " to ") } yat(1 + am ~ minmax(hp), mtcars)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.