# [R] Time Plot Question.

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jul 26 18:30:56 CEST 2003

```x0 <- ISOdate(2003, 7, 13, 0, 0, 0)
x <- x0 + seq(0, 86400)

is what you are asking for, or at least it is in the GMT time zone.

The reason your code is so slow is that expanding vectors by c() is very
wasteful.  If you have pre-allocated x and assigned values by indexing I
think it would have worked (but the above is the optimal way to do this).

On Sat, 26 Jul 2003, John Jaynes wrote:

> Hello,
>
> I have some data (sar -A -f sar_data.file > mydata) that span 24 hours,
> more or less, 00:00:00 - 23:59:59, or so.  I would like to retain and
> plot data for all 24 x 60 x 60 = 86,400 seconds. I am able to set the x
> coordinates equal to ISOdate( year, month, day, hour, minute, second)
> calls. However, ISOdate calls such as
>
> "ISOdate(2003, 7, 13, 7, 0:59, 0:59)"

No, as the recycling rules apply.  You could use expand.grid to create
suitable arguments.

>  do not return all the seconds contained in hour 7. These function calls works:
>
> R> x <- ISOdate(2003, 7, 13, 7)
> R> for(j in 0:59) for(i in 0:59) x <- c(x, ISOdate(2003, 7, 13, 7, j, i )),
>
> assigning all the seconds contained in hour 7, to x.
>
> When I attempt this
>
> for(k in 7:23) for(j in 0:59) for(i in 0:59) x <- c(x, ISOdate(2003, 7, 13, k, j, i )),
>
> my computer hangs, as, I am guessing, this call requires too much memory
> of some sort. I could break up these data and plot 1 Hour blocks, but
> would like to also view this data in a 24 Hour plot. The raw data
> appears as:
>
> Time	              user      nice    system      idle
> 08:42:07             79.00      0.00     21.00      0.00
> 08:42:08             87.00      0.00     13.00      0.00
> 08:42:11             92.24      0.00      7.76      0.00
> 08:42:13             41.09      0.00      3.27     55.64
> 08:42:15             95.67      0.00      4.33      0.00
> 08:42:16             98.00      0.00      2.00      0.00
>
> ...
>
> Is there an easier way to do this? I have read the help pages, but have
> not found one that is applicable. Any help would be greatly appreciated.
> Thanks for making this Very useful program freely available.

--
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

```