This example will use the preloaded dataset Theoph, which has data from an experiment on the pharmacokinetics of the respiratory drug thephylline. By using head on this dataset, we can see what the columns are coded as.
> head(Theoph, n = 1)
Subject Wt Dose Time conc
1 1 79.6 4.02 0 0.74
Knowing how the columns are coded allows you to reference certain columns in
the data set using dataset$columnname
.
With the plot command, you can designate where the data are
(in the following example, the x-axis is Theoph$Time
and the y-axis is
Theoph$conc
. Using xlab
and ylab
sets the axes labels, and pch
chooses
the marker type (seen here).
> setwd("~/Desktop")
> png(filename="theophscatter.png")
> plot(Theoph$Time, Theoph$conc, xlab="Time (min)", ylab="Concentration (M)", pch=16)
> title("Pharmacokinetics of Theophylline")
> dev.off()
quartz
2