Fri Oct 28 02:12:17 2016

Objective

This presentation was performed with R Markdown using Theoph (132x5) data frame from datasets package including the following variables:

  • Subject: the subject on whom the observation was made.
  • Wt: weight of the subject (kg).
  • Dose: dose of theophylline administered orally to the subject (mg/kg).
  • Time: time since drug administration when the sample was drawn (hr).
  • conc: theophylline concentration in the sample (mg/L).

Theoph data.frame

head(Theoph)
  Subject   Wt Dose Time  conc
1       1 79.6 4.02 0.00  0.74
2       1 79.6 4.02 0.25  2.84
3       1 79.6 4.02 0.57  6.57
4       1 79.6 4.02 1.12 10.50
5       1 79.6 4.02 2.02  9.66
6       1 79.6 4.02 3.82  8.58

Theophylline kinetics according to dose expressed in mg/kg

Code

suppressWarnings(suppressPackageStartupMessages(library (plotly)))

pal1<-c("blue","red"); doses<-c("Dose<=4.5","Dose>4.5")

p1<-plot_ly(data = Theoph,x=~Time,y=~conc,
            type = "scatter", mode="markers",
            color = ~Dose>4.5, colors=pal1, 
            name=list(doses))%>%
    add_lines(x = ~Time,y = ~predict(loess(data = Theoph,conc~Time)),
              colors=pal1)%>%
    layout(yaxis=list(title="Theophylline (mg/L)"))%>%
    layout(xaxis=list(title="Time (hr)"))%>%
    style (traces = 1,name=doses[1])%>%
    style (traces = 2,name=doses[2])%>%
    style (traces = 3,name="loess")%>%
    style (traces = 4,name="loess")
    
p1