# [R]How to make the plot when x columns are string list?

Prof Brian D Ripley ripley at stats.ox.ac.uk
Fri Sep 1 08:18:00 CEST 2000

```On Fri, 1 Sep 2000, Shawn Lee wrote:

> Dear R users:
>
> I have to plot the data set like the following.
> x <- c("05/27/00","06/03/00","08/22/00",...)
> y <- c(10,20,15,...)
>
> But plot(x,y,...) do not work!!
> How can i get the proper plot in this kinds of situation.

You need to tell R that x is a date (or at least I presume that is what you
intend).  There are a couple of ways to do this, using packages date and
chron (both on CRAN). Here is one using chron.

library(chron)
x <- dates(c("05/27/00","06/03/00","08/22/00"))
y <- c(10,20,15)
plot(x, y)

which will work if you were in the USA and your first string means 2000 May
27, 2000-05-27 in ISO 8601 date format.  (R 1.2.0 will have facilties to
read those as well as US and European shorthands.)

--
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._

```