Skip to content

New in v0.3.0

Kyle Baron edited this page Nov 19, 2020 · 2 revisions

Kyle Baron 2020-11-19

What does lastdose do?

lastdose calculates time since last dose in your nmtran-like data set

library(lastdose)
library(tidyverse)

data <- read_csv(system.file("csv", "data1.csv", package = "lastdose"))

Calculate after dose and amount of last dose

data %>% lastdose() 
. # A tibble: 508 x 10
.       ID  TIME  EVID   AMT   CMT    II  ADDL    DV   TAD  LDOS
.    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
.  1     1     0     0     0     0     0     0   0       0     0
.  2     1     0     1  1000     1    24    27   0       0  1000
.  3     1     4     0     0     0     0     0  42.1     4  1000
.  4     1     8     0     0     0     0     0  35.3     8  1000
.  5     1    12     0     0     0     0     0  28.9    12  1000
.  6     1    16     0     0     0     0     0  23.6    16  1000
.  7     1    20     0     0     0     0     0  19.4    20  1000
.  8     1    24     0     0     0     0     0  15.9    24  1000
.  9     1    28     0     0     0     0     0  55.1    28  1000
. 10     1    32     0     0     0     0     0  45.9    32  1000
. # … with 498 more rows

User-specified TIME column

  • Previous requirement was that the column was called TIME; now we’ll ask to use TAFD instead
data1 %>% lastdose(time_col = "TAFD")
. # A tibble: 508 x 10
.       ID  TAFD  EVID   AMT   CMT    II  ADDL    DV   TAD  LDOS
.    <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
.  1     1     0     0     0     0     0     0   0       0     0
.  2     1     0     1  1000     1    24    27   0       0  1000
.  3     1     4     0     0     0     0     0  42.1     4  1000
.  4     1     8     0     0     0     0     0  35.3     8  1000
.  5     1    12     0     0     0     0     0  28.9    12  1000
.  6     1    16     0     0     0     0     0  23.6    16  1000
.  7     1    20     0     0     0     0     0  19.4    20  1000
.  8     1    24     0     0     0     0     0  15.9    24  1000
.  9     1    28     0     0     0     0     0  55.1    28  1000
. 10     1    32     0     0     0     0     0  45.9    32  1000
. # … with 498 more rows

Character ID info

  • For example, when you only have USUBJID
  • Previous requirement was ID as numeric
data2 %>% lastdose(id_col = "USUBJID")
. # A tibble: 508 x 10
.    USUBJID            TIME  EVID   AMT   CMT    II  ADDL    DV   TAD  LDOS
.    <chr>             <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
.  1 SOME-STUDY-ID-001     0     0     0     0     0     0   0       0     0
.  2 SOME-STUDY-ID-001     0     1  1000     1    24    27   0       0  1000
.  3 SOME-STUDY-ID-001     4     0     0     0     0     0  42.1     4  1000
.  4 SOME-STUDY-ID-001     8     0     0     0     0     0  35.3     8  1000
.  5 SOME-STUDY-ID-001    12     0     0     0     0     0  28.9    12  1000
.  6 SOME-STUDY-ID-001    16     0     0     0     0     0  23.6    16  1000
.  7 SOME-STUDY-ID-001    20     0     0     0     0     0  19.4    20  1000
.  8 SOME-STUDY-ID-001    24     0     0     0     0     0  15.9    24  1000
.  9 SOME-STUDY-ID-001    28     0     0     0     0     0  55.1    28  1000
. 10 SOME-STUDY-ID-001    32     0     0     0     0     0  45.9    32  1000
. # … with 498 more rows

Use DATETIME to calculate time after dose

This hopefully allows you to calculate TAD earlier in your DA process, for example when you are checking how doses and observations fit together

  • DATETIME should be POSIXct
  • you have to specify the time unit
data3 %>% lastdose(time_col = "DATETIME", time_unit = "hours")
. # A tibble: 508 x 10
.       ID DATETIME             EVID   AMT   CMT    II  ADDL    DV   TAD  LDOS
.    <dbl> <dttm>              <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
.  1     1 2018-02-03 00:00:00     0     0     0     0     0   0       0     0
.  2     1 2018-02-03 00:00:00     1  1000     1    24    27   0       0  1000
.  3     1 2018-02-03 04:00:00     0     0     0     0     0  42.1     4  1000
.  4     1 2018-02-03 08:00:00     0     0     0     0     0  35.3     8  1000
.  5     1 2018-02-03 12:00:00     0     0     0     0     0  28.9    12  1000
.  6     1 2018-02-03 16:00:00     0     0     0     0     0  23.6    16  1000
.  7     1 2018-02-03 20:00:00     0     0     0     0     0  19.4    20  1000
.  8     1 2018-02-04 00:00:00     0     0     0     0     0  15.9    24  1000
.  9     1 2018-02-04 04:00:00     0     0     0     0     0  55.1    28  1000
. 10     1 2018-02-04 08:00:00     0     0     0     0     0  45.9    32  1000
. # … with 498 more rows

Clone this wiki locally