[R] time plotting problem

John Kane jrkrideau at yahoo.ca
Wed Nov 14 17:14:29 CET 2007


Thank you. Almost too fancy for the target user but
very nice indeed.  For some reason I had not thought
of using ggplot2.  


--- hadley wickham <h.wickham at gmail.com> wrote:

> 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