R by example(mayin.org)
mayin.org
R by example
http://www.mayin.org/ajayshah/KB/R/index.html
1 comments
Hey David,
I've just started using R and one thing that I've been looking for is a way to display discrete events on a timeline. It doesn't have to be anything fancy, all I want is to put hours/days on one axis and then put a marker and some text above it. Do you know of any built in libraries that do that?
Something like this: http://www.simile-widgets.org/timeline/
but it doesn't have to be near that nice..
Thanks in advance
I've just started using R and one thing that I've been looking for is a way to display discrete events on a timeline. It doesn't have to be anything fancy, all I want is to put hours/days on one axis and then put a marker and some text above it. Do you know of any built in libraries that do that?
Something like this: http://www.simile-widgets.org/timeline/
but it doesn't have to be near that nice..
Thanks in advance
One of the best all-around plotting packages for R (in my opinion) is Hadley Wickham's ggplot2 .
Take a look at the following pages: http://had.co.nz/ggplot2/scale_datetime.html http://had.co.nz/ggplot2/geom_line.html
While not specifically inentended as a 'time-series' package, ggplot2's facilities handle time-series data well. Ggplot2 is available on CRAN (i.e. install.packages('ggplot2'); ).
In truth, you don't even have to use a special package if the 'prettiness isn't important.'
df <- data.frame( day7 = start + round(runif(100, max = 7 * 86400)), hour10 = start + round(runif(100, max = 10 * 3600)), y = runif(100) ); plot(df$day7, df$y); plot(df$hour10, df$y);
Take a look at the following pages: http://had.co.nz/ggplot2/scale_datetime.html http://had.co.nz/ggplot2/geom_line.html
While not specifically inentended as a 'time-series' package, ggplot2's facilities handle time-series data well. Ggplot2 is available on CRAN (i.e. install.packages('ggplot2'); ).
In truth, you don't even have to use a special package if the 'prettiness isn't important.'
df <- data.frame( day7 = start + round(runif(100, max = 7 * 86400)), hour10 = start + round(runif(100, max = 10 * 3600)), y = runif(100) ); plot(df$day7, df$y); plot(df$hour10, df$y);
Excellent, thanks.
The Sweave/LaTeX source is also available if anyone is interested.