Here's a version using reshape and ggplot:

mydata <- read.table("http://ca.geocities.com/jrkrideau/R/heartdata.txt";,
sep="\t", header=FALSE)

mydata[,1] <- as.Date(mydata[,1],"%m/%d/%y")
names(mydata) <- c("dates", "sy","dys","pulse", "weight")

molten <- melt(mydata, m = c("sy", "dys"))
qplot(dates, value, data=molten, geom="line", colour=variable) +
geom_smooth(method=lm)


ggplot has somewhat better defaults for dates in this case.  See
http://had.co.nz/ggplot2/scale_date.html for how to tweak the
defaults.

Hadley

-- 
http://had.co.nz/

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to