first_table | R Documentation |
First Table
first_table(
.data,
...,
.column_variable = NULL,
.column_type = c("default", "numeric"),
.options = first_table_options()
)
.data |
'data.frame' or 'tibble' to use as data source |
... |
row details |
.column_variable |
variable used for columns (if any) |
.column_type |
type of column (default or numeric) |
.options |
options to use for formatting (see details) |
This function takes a data.frame
or tibble
and a row and column specification and generates a table along the lines of the first table
used in many medical journal articles. The row specification can either use one of the _row
functions, or if the defaults are appropriate can just be a bare column name or calculation
using a column. These calculations are implemented using eval_tidy
and
support the quasiquotation
operators such as !!
and
!!!
.
Options can be specified as a list or by using first_table_options
.
object of class first_table
with the requested rows and columns;
first_table(mtcars,
.column_variable = cyl,
"Miles per gallon" = mpg,
"Transmission" = factor(am))
# Example demonstrating use of quasiquotation from rlang
library(rlang)
my_rows <- quos(
kruskal_row(Sepal.Length, row_digits = 0),
"Sepal width" = first_table_row(Sepal.Width, row_digits = 2),
"Wide petals" = Petal.Width > median(Petal.Width)
)
first_table(iris,
.column_variable = Species,
!!!my_rows
)
# Example demonstrating use of survival column variable
library(survival)
first_table(lung,
.column_variable = Surv(time, status),
.options = list(include_n = TRUE, include_n_per_col = TRUE),
ECOG = factor(ph.ecog),
`Meal calories` = first_table_row(meal.cal, row_digits = 2)
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.