[R] time plotting problem

hadley wickham h.wickham at gmail.com
Wed Nov 14 01:00:51 CET 2007


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/



More information about the R-help mailing list