Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when intervals are a tibble #141

Closed
billdenney opened this issue Mar 17, 2021 · 1 comment
Closed

Error when intervals are a tibble #141

billdenney opened this issue Mar 17, 2021 · 1 comment
Labels

Comments

@billdenney
Copy link
Owner

From testing related to #140

library(PKNCA)
library(tidyverse, quietly=TRUE)
#> Warning: package 'tibble' was built under R version 4.0.4
options(warn=1)

e.dat <-
  data.frame(
    conc=c(0.5,2,5,9.2,12,2,1.85,1.08,0.5,0.3,2.4,4.5,10.2,15,2.6,1.65,1.1,
           0.5,2,5,9.2,12,2,1.85,1.08,NA,0.3,2.4,4.5,10.2,15,2.6,1.65,1.1),
    time=c(seq(264.2,312.2,3),seq(264,312,3)),
    ARM=rep(c(rep(1,8),rep(2,9)),2),
    SUBJ=c(rep(1,17),rep(2,17)),
    Dose=c(rep(5,17)),rep(5,17)
  )

## Generate the dosing data
d_dose <- e.dat %>% distinct(SUBJ,Dose,ARM) %>% mutate(time=rep(c(264,288),2))
# d_dose$Time <- 0

conc_obj <-
  PKNCAconc(
    e.dat,
    conc~time|SUBJ + ARM
  )
dose_obj <-
  PKNCAdose(
    d_dose,
    Dose~time|SUBJ + ARM
  )  
## Calculate the NCA parameters
intervals_manual_first <-
  e.dat %>%
  group_by(SUBJ) %>%
  summarize(
    start=time[between(time, 264, 265)],
    end=time[between(time, 288, 289)]
  )
intervals_manual_second <-
  e.dat %>%
  group_by(SUBJ) %>%
  summarize(
    start=time[between(time, 288, 289)],
    end=time[between(time, 312, 313)]
  )
intervals_manual <-
  bind_rows(intervals_manual_first, intervals_manual_second) %>%
  mutate(
    auclast=TRUE,
    aucall=TRUE,
    tlast=TRUE
  )
as.data.frame(intervals_manual)
#>   SUBJ start   end auclast aucall tlast
#> 1    1 264.2 288.2    TRUE   TRUE  TRUE
#> 2    2 264.0 288.0    TRUE   TRUE  TRUE
#> 3    1 288.2 312.2    TRUE   TRUE  TRUE
#> 4    2 288.0 312.0    TRUE   TRUE  TRUE

# There is some other issue here where intervals are having an issue being a tibble
data_obj <- PKNCAdata(conc_obj, dose_obj, intervals=intervals_manual)
#> Error in interval_cols[[n]]$values(x[, n]): 'list' object cannot be coerced to type 'double'

results_obj <- pk.nca(data_obj)
#> Error in nrow(data$intervals): object 'data_obj' not found
as.data.frame(results_obj, out.format = "wide")
#> Error in as.data.frame(results_obj, out.format = "wide"): object 'results_obj' not found

Created on 2021-03-17 by the reprex package (v1.0.0)

@billdenney
Copy link
Owner Author

Fixed in #146

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant