[R] Problem using plot and converted dates

Gabor Grothendieck ggrothendieck at gmail.com
Mon Apr 17 18:46:19 CEST 2006


Try:

y <- 1:length(sam4) # test data
dd <- as.Date(sam4, "%m/%d/%y")
plot(dd, y)

# also try this
library(zoo)
z <- zoo(y, dd)
plot(z)

Also read, from earlier today:

https://www.stat.math.ethz.ch/pipermail/r-help/2006-April/092471.html



On 4/17/06, s.e.roberts at qmul.ac.uk <s.e.roberts at qmul.ac.uk> wrote:
> Dear R-help,
> I am having problems with plotting converted dates in chronological as Mar-03,
> May-03...Jul-04.
> My script is:
>
> sam4<-c("03/03/01","03/05/01","03/07/01","03/09/01","03/11/01","04/01/01","04/03/01","04/05/01","04/07/01")
> sam5<-strptime(sam4,format="%y/%m/%d")
> f<-data.frame(sam5,mkf)
> plot(f,type="l")
> # This works ok, but none of the labels appear on the x-axis, so I thought I
> would convert them using
> # as.POSIXct:
>
> sam6<-format(as.POSIXct(sam5), "%b-%y")
> mon<-factor(as.character(sam6),levels=sam6)
> f2<-data.frame(mon,mkf)
> plot(f2,type="l")
>
> The problem is that plot(f2,type="l") no longer produces a line plot...
>
> Any help with this would be gratefully appreciated.
>
> Best wishes,
> Sion
>
>
> --
> Siôn Roberts
>
> Department of Geography,
> Queen Mary, University of London,
> London,
> E1 4NS.
>
> Tel: +44 20 7882 5400
> http://www.geog.qmul.ac.uk/postgraduate/student/roberts.html
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list