metrumresearchgroup / mrgsolve

Simulate from ODE-based population PK/PD and QSP models in R
https://mrgsolve.org
GNU General Public License v2.0
131 stars 36 forks source link

Refactor dropped non-numeric columns with recover #1193

Closed kylebaron closed 6 months ago

kylebaron commented 6 months ago

Summary

See #1184

library(mrgsolve)
#> 
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#> 
#>     filter
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

mod <- house(end = 0)

data <- expand.ev(amt = 100, WTVC = "a")

mrgsim(mod, idata = data)
#> Error in `valid_idata_set()`:
#> ! Found input data that cannot be used for simulation
#> ✖ idata set column: WTVC (character)
#> Backtrace:
#>     ▆
#>  1. └─mrgsolve::mrgsim(mod, idata = data)
#>  2.   └─mrgsolve::mrgsim_i(x, idata = idata, ...)
#>  3.     ├─base::do.call(...)
#>  4.     └─mrgsolve (local) `<fn>`(x = `<packmod>`, data = `<int[,1]>`, idata = `<df[,6]>`)
#>  5.       └─mrgsolve::valid_idata_set(idata, x, verbose = verbose)
#>  6.         └─mrgsolve:::signal_drop(dm, x, to_signal, context = "idata set")
#>  7.           └─rlang::abort(...)

mrgsim(mod, idata = data, recover = "WTVC")
#> Error in `valid_idata_set()`:
#> ! Found input data that cannot be used for simulation
#> ✖ idata set column: WTVC (character)
#> Backtrace:
#>     ▆
#>  1. └─mrgsolve::mrgsim(mod, idata = data, recover = "WTVC")
#>  2.   └─mrgsolve::mrgsim_i(x, idata = idata, ...)
#>  3.     ├─base::do.call(...)
#>  4.     └─mrgsolve (local) `<fn>`(...)
#>  5.       └─mrgsolve::valid_idata_set(idata, x, verbose = verbose)
#>  6.         └─mrgsolve:::signal_drop(dm, x, to_signal, context = "idata set")
#>  7.           └─rlang::abort(...)

Created on 2024-05-21 with reprex v2.0.2