# Example I: Single subject IV bolus data
df <- data.frame(
time = c(0.25, 0.5, 1, 2, 4, 6, 8, 12),
concentration = c(18.2, 16.1, 13.5, 10.2, 6.8, 4.9, 3.6, 2.1)
)
one_compartment_iv_bolus(
data = df,
time_col = "time",
conc_col = "concentration",
dose = 100
)
# Example II: Condition-dependent pharmacokinetics (e.g., pH or physiological state)
df_cond <- data.frame(
time = rep(c(0.25, 0.5, 1, 2, 4, 6), 2),
concentration = c(
17.8, 15.6, 13.1, 9.8, 6.4, 4.8, # Condition A
14.9, 13.0, 10.9, 8.0, 5.2, 3.9 # Condition B
),
condition = rep(c("Condition A", "Condition B"), each = 6)
)
one_compartment_iv_bolus(
data = df_cond,
time_col = "time",
conc_col = "concentration",
dose = 100,
group_col = "condition"
)
# Example III: Multiple subjects (population-style IV bolus pharmacokinetics)
df_subjects <- data.frame(
time = rep(c(0.25, 0.5, 1, 2, 4, 6, 8), 6),
concentration = c(
18.6, 16.3, 13.9, 10.5, 7.0, 5.1, 3.8, # Subject 1
17.9, 15.7, 13.2, 9.9, 6.6, 4.9, 3.6, # Subject 2
17.1, 15.0, 12.6, 9.4, 6.3, 4.7, 3.4, # Subject 3
16.4, 14.4, 12.0, 9.0, 6.0, 4.4, 3.2, # Subject 4
15.8, 13.9, 11.6, 8.7, 5.8, 4.2, 3.1, # Subject 5
15.2, 13.3, 11.0, 8.3, 5.5, 4.0, 2.9 # Subject 6
),
subject = rep(paste0("S", 1:6), each = 7)
)
one_compartment_iv_bolus(
data = df_subjects,
time_col = "time",
conc_col = "concentration",
dose = 100,
group_col = "subject"
)
Run the code above in your browser using DataLab