billdenney / pknca

An R package is designed to perform all noncompartmental analysis (NCA) calculations for pharmacokinetic (PK) data.
http://billdenney.github.io/pknca/
GNU Affero General Public License v3.0
67 stars 24 forks source link

Unexpected interval column can cause error #238

Closed billdenney closed 12 months ago

billdenney commented 12 months ago
library(PKNCA)
#> 
#> Attaching package: 'PKNCA'
#> The following object is masked from 'package:stats':
#> 
#>     filter
d_conc <-
  data.frame(
    ID = 1L,
    time = 0:6,
    conc = c(0, 0.7, 0.71, 0.85, 1, 0.76, 0.74)
  )
d_intervals <- data.frame(start = 0, end = 6, cmax = TRUE, aucinf = TRUE)
o_conc <- PKNCAconc(d_conc, formula = conc~time|ID)
o_data <- PKNCAdata(o_conc, intervals = d_intervals)
o_nca <- pk.nca(o_data)
#> No dose information provided, calculations requiring dose will return NA.
#> Error in `purrr::pmap()`:
#> ℹ In index: 1.
#> Caused by error in `vapply()`:
#> ! values must be length 1,
#>  but FUN(X[[2]]) result is length 0
#> Backtrace:
#>      ▆
#>   1. ├─PKNCA::pk.nca(o_data)
#>   2. │ └─purrr::pmap(...)
#>   3. │   └─purrr:::pmap_("list", .l, .f, ..., .progress = .progress)
#>   4. │     ├─purrr:::with_indexed_errors(...)
#>   5. │     │ └─base::withCallingHandlers(...)
#>   6. │     ├─purrr:::call_with_cleanup(...)
#>   7. │     └─PKNCA (local) .f(...)
#>   8. │       └─PKNCA:::any_sparse_dense_in_interval(current_interval, sparse = sparse)
#>   9. │         ├─... %in% sparse
#>  10. │         └─base::vapply(...)
#>  11. └─base::.handleSimpleError(...)
#>  12.   └─purrr (local) h(simpleError(msg, call))
#>  13.     └─cli::cli_abort(...)
#>  14.       └─rlang::abort(...)

Created on 2023-09-10 with reprex v2.0.2