metrumresearchgroup / pmplots

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

Vectorized plots accept lists of col//labels #95

Closed kylebaron closed 3 months ago

kylebaron commented 3 months ago

Using [[ to subset should work for both list and vector.

The original idea was to implement for displays (e.g., npde_covariate()) but expanded to accept lists for all vectorized plots.

Example

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
library(purrr)
library(patchwork)
library(yspec)

spec <- ys_help$spec()
co <- spec %>% ys_select(WT, AGE) %>% axis_col_labs() %>% as.list()

data <- ys_help$data() %>% mutate(NPDE = rnorm(n()), CWRES = NPDE)

npde_covariate(data, co)
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'


npde_cont(data, co)
#> [[1]]
#> `geom_smooth()` using formula = 'y ~ x'

#> 
#> [[2]]
#> `geom_smooth()` using formula = 'y ~ x'

Created on 2024-07-10 with reprex v2.0.2