pt_cont_wide: Continuous data summary in wide format

View source: R/continuous_table.R

pt_cont_wideR Documentation

Continuous data summary in wide format

Description

This function summarizes your data in a specific way and returns an object that can be converted into a latex table.

Usage

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"
)

Arguments

data

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

cols

the columns to summarize; may be character vector or quosure

by

a grouping variable; may be character vector or quosure

panel

data set column name to stratify the summary

table

a named list to use for renaming columns (see details and examples)

units

a named list to use for unit lookup (see details and examples)

digits

a digits object (see new_digits())

all_name

a name to use for the complete data summary

fun

the data summary function (see details)

na_fill

value to fill with when all values in the summary are missing

id_col

the ID column name

Details

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().

Value

An object with class pmtable; see class-pmtable.

Custom summary function

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.

Examples

pmtables:::cont_wide_fun(rnorm(100))

out <- stable(pt_cont_wide(pmt_first, cols = "AGE,WT,SCR"))
out

## Not run: 
st2report(out)

## End(Not run)


metrumresearchgroup/pmtables documentation built on Oct. 27, 2024, 5:16 p.m.