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. Sorry for kinds of simple question!! best regards, Shawn Lee -------------- next part -------------- A non-text attachment was scrubbed... Name: Shawn.Lee.vcf Type: text/x-vcard Size: 298 bytes Desc: Card for Shawn Lee Url : https://stat.ethz.ch/pipermail/r-help/attachments/20000901/c1dd0ecc/Shawn.Lee.vcf
Prof Brian D Ripley
2000-Sep-01 06:18 UTC
[R]How to make the plot when x columns are string list?
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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. > Sorry for kinds of simple question!!You should try the package "date", available at CRAN. Example: library(date) x <- as.date(c("05/27/2000","06/03/2000","08/22/2000")) y <- c(10,20,15) plot(x,y) Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._