Re: [R] interactive time series plot

From: Greg Snow <>
Date: Tue 30 Aug 2005 - 05:29:22 EST

I don't think that the par(ask=T) will do it for you. Some alternatives to try:

  1. use the slider function in either the relax package or the TeachingDemos package to create a Tk slider that you move back and forth with the mouse and have the graph update accordingly.
  2. Use locator(1) to have the user advance the graph by clicking and have your function determine the direction moved based on if they click on the right or left part of the graph (see put.points.demo in TeachingDemos package for an example).
  3. Use the readline function to prompt for keyboard input and move the

    window based on the keyboard input.

hope this helps,

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
(801) 408-8111

>>> "Chris Paulse" <> 08/29/05 12:03PM >>>

I've written the following function to display small windows of a time series (and a processed version of it) with mouse clicks used to move the
window forward.  

ViewRawAndProcessed <- function(raw, processed, width=1000)


      len <- length(raw)

      n <- round(len/width)

      for (i in 1:n)


            plot(raw[((i-1)*width):(i*width)], type="s")

            lines(processed[((i-1)*width):(i*width)], type="s", col="red")

            s <- sprintf("%d - %d", (i-1)*width,(i*width))





What I'd like to do is modify the function so that it stays within a loop
and accepts right and left cursor keys (or h and l) to shift the current
window backwards and forwards (with the q key causing a break from the loop).  

Is this possible with the par(ask=TRUE) command?  


Chris Paulse

        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide! mailing list PLEASE do read the posting guide! Received on Tue Aug 30 05:42:34 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:58 EST