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

We can re-name the various column names in the output table

Rename via list

We make a named list with re-names for each column we are summarizing or paneling by.

table <- list(WT = "weight", BMI = "body mass index", SCR = "serum creatinine")

Here we created the list manually; you can also pull this information out of the data specification object.

Example

We pass this table list into the continuous covariate table function

library(pmtables)
library(dplyr)

data <- pmtables:::data("id")

pt_cont_long(
  data, 
  cols = "BMI,SCR,WT", 
  table = table
)

Rename inline

Rather than creating that list of renames, we can re-name in line using the vars constructor

pt_cat_wide(
  data, 
  cols = vars(Sex = SEXf, Formaulation = FORMf), 
  by = vars("Study ID" = STUDYf)
)

We can also rename the panel or by variable

obs <- pmtables:::data("obs")

pt_data_inventory(
  obs, 
  by = vars(Sex = SEXf), 
  panel = vars(Formulation = FORMf)
)

Use R to rename factor levels

Remember, you are on the hook to label or relabel your factors

data2 <- mutate( data, SEXf = factor(SEXf, labels = c("dude", "gal")))

pt_cat_wide(
  data2, 
  cols = vars(Sex = SEXf, Formulation = FORMf), 
  by = vars("Study ID" = STUDYf)
)


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