[R] Problem using plot and converted dates
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Apr 17 19:28:39 CEST 2006
On Mon, 17 Apr 2006, s.e.roberts at qmul.ac.uk wrote:
Please do follow the posting guide and at least tell us your version of R
and give a working example (mkf is missing)
> Dear R-help,
> I am having problems with plotting converted dates in chronological as Mar-03,
> My script is:
I would suggest you use as.Date here, for you have dates, not date-times.
> # This works ok, but none of the labels appear on the x-axis,
It works for me: it is not intended to plot your labels (and plot.default
does not do that either). If you want add a special axis, use axis.Date
to do so.
> so I thought I
> would convert them using
> # as.POSIXct:
You have converted them to a factor, which is not what you want.
> sam6<-format(as.POSIXct(sam5), "%b-%y")
> The problem is that plot(f2,type="l") no longer produces a line plot...
Why don't you use plot(sam5, mkf, type="l")? That works, and in fact
your example works in R 2.3.0RC, but creating a data frame you don't need
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
More information about the R-help