[R] time plotting problem

jim holtman jholtman at gmail.com
Mon Nov 12 21:16:38 CET 2007


So what is wrong with the plots?  I used your example, and it appears
to plot the data correctly.  What were you expecting?

On Nov 12, 2007 1:47 PM, John Kane <jrkrideau at yahoo.ca> wrote:
> I am completely misunderstanding how to handle dates.
> I want to plot a couple of data series against some
> dates.  Simple example 1 below works fine.
> Unfortunately I have multiple observations per day (no
> time breakdowns) and observations across years.
> (example 2 very simplistic version )
>
> Can anyone suggest a quick fix or point me to
> something to read?  I thought that zoo might do it but
> I seem to be missing something there too.
>
> Any suggestions gratefully recieved.
>
>
> Example 1 consecutive dates same year.
> =================================================
> x <- "days
> 9/26/09
> 9/27/06
> 9/28/06
> 9/29/06
> 9/29/06
> 9/29/06
> 10/1/06
> 10/1/06
> 10/2/06
> 10/3/06"
>
> mydata <- read.table(textConnection(x), header=TRUE,
> as.is=TRUE); mydata
>
> mydates <- as.Date(mydata[,1], "%m/%d/%y"); mydates
> mynums <- rnorm(10)
> plot(mydates, mynums)
> ================================================
> Example 2 (things go blooy!)
> non-consecutive dates different years.
>
> =================================================
> x <- "days
> 9/26/09
> 9/27/06
> 9/28/06
> 9/29/06
> 9/29/06
> 9/29/06
> 10/1/07  # <- year changes
> 10/1/07
> 10/2/07
> 10/3/07"
>
> mydata <- read.table(textConnection(x), header=TRUE,
> as.is=TRUE); mydata
>
> mydates <- as.Date(mydata[,1], "%m/%d/%y"); mydates
> mynums <- rnorm(10)
> plot(mydates, mynums)
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list