metrumresearchgroup / pmplots

Plots for Pharmacometrics
https://metrumresearchgroup.github.io/pmplots
8 stars 1 forks source link

One-liner panels of continuous covariate boxplots #81

Closed kylebaron closed 8 months ago

kylebaron commented 8 months ago

Summary

Add on to what was merged in #77. This creates continuous versus categorical plots with similar syntax.

Housekeeping

Examples

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(pmplots)
#> Loading required package: ggplot2

data <- pmplots_data_obs()
id <- dplyr::distinct(data, ID, .keep_all = TRUE)

conts <- c("AAG//AAG (IU/ml)", "SCR//Creatinine (mg/dL)", "AST//AST (IU/ml)",
           "AGE//Age (years)")
cats <- c("RF//Renal function", "CPc//Child-Pugh", "STUDYc//Study")

a <- cont_cat_panel(id, cats, conts, tag_levels = "A")

a[[1]]

a[[2]]


b <- cont_cat_panel(id, cats, conts, transpose = TRUE, byrow = FALSE)
b[[1]]

b[[2]]


l <- cont_cat_panel_list(id, cats, conts, transpose = TRUE)
with(l$RF, (AAG+SCR)/AST, tag_levels = "a")

Created on 2024-01-30 with reprex v2.0.2

kylebaron commented 8 months ago

Thanks, @kyleam