metrumresearchgroup / lastdose

Fast computation of [time since] and [amount of] the most-recent dose in a data set
3 stars 2 forks source link

Comments vector are not getting subset when TIME is missing #37

Closed kylebaron closed 2 years ago

kylebaron commented 2 years ago

Not totally sure what's going on

library(lastdose)

data <- data.frame(
  ID = c(1,1,1,2,2,2),
  C = c("C", NA, NA, "C", NA, NA),
  TIME = c(-1, 0, NA, -1, 0, 0.25),
  AMT = c(0, 100, 0, 0, 200, 0),
  EVID = c(0, 1, 0, 0, 1, 0)
)

lastdose(data)
#>   ID    C  TIME AMT EVID TAD LDOS
#> 1  1    C -1.00   0    0  -1    0
#> 2  1 <NA>  0.00 100    1   0  100
#> 3  1 <NA>    NA   0    0  NA   NA
#> 4  2    C -1.00   0    0 -99    0
#> 5  2 <NA>  0.00 200    1 -99    0
#> 6  2 <NA>  0.25   0    0 -99    0

Created on 2022-05-05 by the reprex package (v2.0.1)

kylebaron commented 2 years ago

Fixed

library(lastdose)

data <- data.frame(
  ID = c(1,1,1,2,2,2),
  C = c("C", NA, NA, "C", NA, NA),
  TIME = c(-1, 0, NA, -1, 0, 0.25),
  AMT = c(0, 100, 0, 0, 200, 0),
  EVID = c(0, 1, 0, 0, 1, 0)
)

lastdose(data)
#>   ID    C  TIME AMT EVID   TAD LDOS
#> 1  1    C -1.00   0    0 -1.00    0
#> 2  1 <NA>  0.00 100    1  0.00  100
#> 3  1 <NA>    NA   0    0    NA   NA
#> 4  2    C -1.00   0    0 -1.00    0
#> 5  2 <NA>  0.00 200    1  0.00  200
#> 6  2 <NA>  0.25   0    0  0.25  200

Created on 2022-05-05 by the reprex package (v2.0.1)