knitr::opts_chunk$set(
collapse = TRUE,
comment = "."
)

For continuous data summaries, the number of digits can be controlled by setting the digits option with a digits object.

Digits objects

Create a new digits object

library(pmtables)

x <- new_digits()
x

By default, pmtables will format numeric summaries with 3 significant digits.

Select number of digits by default

To use a default of 2 significant digits

x <- new_digits(.default = 2)
x

To customize the number of digits for each data summary

x <- new_digits(WT = 3, ALB = 4, SCR = 2)

x

This will use 3 significant digits for WT, 4 for ALB and 2 for SCR.

Select the function to use for digits

We can also round digits. It is safest to create your own wrapper for round instead of using round (a primitive function)

x <- new_digits(.fun = round)
x

Using custom digits

Use the digits option

This should give us 2 digits in all columns except for WT, which should be 3 digits

dig <- new_digits(.default = 2, WT = 3)
dig
pt_opts$set(digits = dig)
data <- pmtables:::data("id")
pt_cont_long(
  data, 
  cols = "WT,ALB,SCR,CRCL"
)


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