# Example I: Single subject oral dosing
df <- data.frame(
time = c(0.25, 0.5, 1, 2, 4, 6, 8, 12),
concentration = c(1.2, 2.8, 5.1, 6.4, 5.2, 4.1, 3.0, 1.8)
)
one_compartment_oral_nl(
data = df,
time_col = "time",
conc_col = "concentration",
dose = 100
)
# Example II: Condition-dependent oral pharmacokinetics (e.g., formulation or pH effect)
df_cond <- data.frame(
time = rep(c(0.25, 0.5, 1, 2, 4, 6, 8), 2),
concentration = c(
1.4, 3.1, 5.6, 6.8, 5.9, 4.7, 3.6, # Condition A
0.9, 2.2, 4.1, 5.3, 4.8, 3.9, 3.0 # Condition B
),
condition = rep(c("Condition A", "Condition B"), each = 7)
)
one_compartment_oral_nl(
data = df_cond,
time_col = "time",
conc_col = "concentration",
dose = 100,
group_col = "condition"
)
# Example III: Multiple subjects (population-style oral pharmacokinetics)
df_subjects <- data.frame(
time = rep(c(0.25, 0.5, 1, 2, 4, 6, 8, 12), 6),
concentration = c(
1.3, 3.0, 5.4, 6.7, 5.8, 4.6, 3.5, 2.3, # Subject 1
1.1, 2.7, 5.0, 6.3, 5.5, 4.4, 3.3, 2.2, # Subject 2
1.0, 2.5, 4.7, 6.0, 5.3, 4.2, 3.2, 2.1, # Subject 3
0.9, 2.3, 4.4, 5.7, 5.0, 4.0, 3.0, 2.0, # Subject 4
0.8, 2.1, 4.1, 5.4, 4.8, 3.8, 2.9, 1.9, # Subject 5
0.7, 2.0, 3.9, 5.2, 4.6, 3.7, 2.8, 1.8 # Subject 6
),
subject = rep(paste0("S", 1:6), each = 8)
)
one_compartment_oral_nl(
data = df_subjects,
time_col = "time",
conc_col = "concentration",
dose = 100,
group_col = "subject"
)
Run the code above in your browser using DataLab