pt_cont_wide.Rd
This function summarizes your data in a specific way and returns an object
that can be converted into a latex
table.
pt_cont_wide(
data,
cols,
by = ".total",
panel = by,
table = NULL,
units = NULL,
digits = new_digits(),
all_name = "All data",
fun = cont_wide_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
a grouping variable; may be character vector or quosure
data set column name to stratify the summary
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()
)
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.
The default summary function is cont_wide_fun()
. Please review that
documentation for details on the default summary for this table.
The notes for this table are generated by pt_cont_wide_notes()
.
The summary function (fun
) should take value
as the first argument and
return a data frame or tibble with one row and one column named summary
.
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_wide_fun()
for details on the default
implementation.
pmtables:::cont_wide_fun(rnorm(100))
#> # A tibble: 1 × 1
#> summary
#> <chr>
#> 1 0.0466 (0.964) [100]
out <- stable(pt_cont_wide(pmt_first, cols = "AGE,WT,SCR"))
out
#> [1] "\\setlength{\\tabcolsep}{5pt} "
#> [2] "\\begin{threeparttable}"
#> [3] "\\renewcommand{\\arraystretch}{1.3}"
#> [4] "\\begin{tabular}[h]{lll}"
#> [5] "\\hline"
#> [6] "AGE & WT & SCR \\\\"
#> [7] "\\hline"
#> [8] "33.7 (8.83) [160] & 70.7 (12.8) [157] & 1.36 (0.986) [160] \\\\"
#> [9] "\\hline"
#> [10] "\\end{tabular}"
#> [11] "\\begin{tablenotes}[flushleft]"
#> [12] "\\item Summary is mean (sd) [count]"
#> [13] "\\end{tablenotes}"
#> [14] "\\end{threeparttable}"
#> attr(,"class")
#> [1] "stable"
if (FALSE) {
st2report(out)
}