| counts_df | R Documentation |
This function calculates and reports counts and frequencies stratified by one or more variables within a data frame
counts_df(
data,
by,
id = NULL,
style = 1,
ret = "tbl",
capt = "Information multiple data frames",
align = NULL,
size = "\\footnotesize",
...
)
data |
data frame for which the table should be created |
by |
character identifying by variables within the data frame for stratification |
id |
character identifying the ID variable within the data frame (see details) |
style |
numeric with the type of output to return (see details) |
ret |
a character vector to define what kind of output should be returned (either "dfrm", "tbl", "file") |
capt |
character with the caption of the table (not used in case data frame is returned) |
align |
alignment of the table passed to general_tbl (not used in case data frame is returned) |
size |
character with font size as for the table general_tbl |
... |
additional arguments passed to general_tbl |
This function generates frequency tables, by default for the number of observation per strata. In case the id argument is used the function will also report the number and frequencies of distinct IDs. By default the observations and percentages are reported in separate columns (convenient for further processing). In case style is set to a value of 2, a single column is created that holds the observations and percentages in a formatted ways (convenient for tabulating)
a data frame, code for table or nothing in case a PDF file is created
Richard Hooijmaijers
data("Theoph")
Theoph$trt <- ifelse(as.numeric(Theoph$Subject)<6,1,2)
Theoph$sex <- ifelse(as.numeric(Theoph$Subject)<4,1,0)
counts_df(data=Theoph, by=c("trt","sex"),id="Subject", ret="dfrm")
counts_df(data=Theoph, by="sex",id="Subject", ret="dfrm")
counts_df(data=Theoph, by=c("trt","sex"),id="Subject", style=2, ret="dfrm")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.