This function summarizes your data in a specific way and returns an object
that can be converted into a latex table.
pt_cont_long(
data,
cols,
panel = ".total",
by = NULL,
table = NULL,
units = NULL,
digits = new_digits(),
summarize_all = TRUE,
all_name = "All data",
fun = cont_long_fun,
na_fill = "--",
id_col = "ID"
)the data frame to summarize; the user should filter or subset
so that data contains exactly the records to be summarized; pmtables will
not add or remove rows prior to summarizing data
the columns to summarize; may be character vector or quosure
data set column name to stratify the summary
a grouping variable that will silently overwrite the value of
panel if panel is also passed; see details and the differences in table
output when either panel or by are passed
a named list to use for renaming columns (see details and examples)
a named list to use for unit lookup (see details and examples)
a digits object (see new_digits())
if TRUE then a complete data summary will be appended
to the bottom of the table
a name to use for the complete data summary
the data summary function (see details)
value to fill with when all values in the summary are missing
the ID column name
An object with class pmtable; see class-pmtable.
Passing the panel variable will partition the table in panels defined by
the non-repeating values of that data column, and cols will form the rows
within each panel. Alternatively, passing in the by variable will panel by
the different levels of cols and the levels of by will form the rows
within each panel.
The default summary function is cont_long_fun(). Please review that
documentation for details on the default summary for this table.
The notes for this table are generated by pt_cont_long_notes().
The summary function (fun) should take value as the first argument and
return a data frame or tibble with one row as many columns as you wish to
appear in the table. The function can also accept an id argument which is
a vector of IDs that is the same length as value. Be sure to include
... to the function signature as other arguments will be passed along.
Make sure your function completely formats the output ... it will appear in
the table as you return from this function. See cont_long_fun() for
details on the default implementation.
ans <- pt_cont_long(pmt_first, cols = dplyr::vars(WT,ALB,CRCL))
ans <- pt_cont_long(pmt_first, cols = "WT,CRCL", panel = "SEXf")
ans <- pt_cont_long(pmt_first, cols = "WT,CRCL", by = "SEXf")
pmtables:::cont_long_fun(rnorm(100))
#> # A tibble: 1 × 5
#> n Mean Median SD `Min / Max`
#> <chr> <chr> <chr> <chr> <chr>
#> 1 100 0.0228 0.0515 1.03 -2.18 / 2.16