Dear List, What is the way in R to plot a graph having date time (e.g. format 12/31/2002 13:12) in the x axis and numerical value (e.g. temperature) on the Y-axis ? I could not get 'plot()' to do this as X axis values are non-numeric. 'bwplot()' sorts the date values and thereby changes the order of the dates and of Y. The date/time values have to be shown on the X-axis as tick values rotated by 90 deg. as there more than 100 points. I appreciate your suggestions and hints. Thanks sukhaswami Lexicon Genetics *************************************************************************** The contents of this communication are intended only for the addressee and may contain confidential and/or privileged material. If you are not the intended recipient, please do not read, copy, use or disclose this communication and notify the sender. Opinions, conclusions and other information in this communication that do not relate to the official business of my company shall be understood as neither given nor endorsed by it. *************************************************************************** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Friday 01 November 2002 02:24 pm, Malladi, Sukhaswami wrote:> Dear List, > > What is the way in R to plot a graph having date time (e.g. format > 12/31/2002 13:12) in the > x axis and numerical value (e.g. temperature) on the Y-axis ?If you have your dates as strings, you need to use strptime() to convert that into date-time objects first.> I could not get 'plot()' to do this as X axis values are non-numeric. > 'bwplot()' sorts the date > values and thereby changes the order of the dates and of Y. The date/time > values have to be > shown on the X-axis as tick values rotated by 90 deg. as there more than > 100 points. > > I appreciate your suggestions and hints. > > Thanks > sukhaswami > Lexicon Genetics > > > *************************************************************************** > The contents of this communication are intended only for the addressee and > may contain confidential and/or privileged material. If you are not the > intended recipient, please do not read, copy, use or disclose this > communication and notify the sender. Opinions, conclusions and other > information in this communication that do not relate to the official > business of my company shall be understood as neither given nor endorsed by > it. > *************************************************************************** > > > -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- >.-.- 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 > _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._ >._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Dear dr.Sarkar, Thanks for your response. My dates are already formatted. I was having problems to display them as X-axis tick labels. I was searching the archives and found axis() to be relevant. I played with its parameters a little and got what I wanted :- If V1 is a list of Dates, V2 list of Times, V3 list of Temperatures, vx <- as.character(paste(V1,V2,sep=" ")) plot(V3,main="Temperature plot",xlab="",xaxt="n", type="o", ylab="Temp. in Deg.") axis(1,1:length(vx),labels=vx,cex.axis=0.6,las=2) Thanks again sukhaswami -----Original Message----- From: Deepayan Sarkar [mailto:deepayan at stat.wisc.edu] Sent: Friday, November 01, 2002 5:58 PM To: Malladi, Sukhaswami; r-help at stat.math.ethz.ch Subject: Re: [R] Line plot with date-time on X-axis On Friday 01 November 2002 02:24 pm, Malladi, Sukhaswami wrote:> Dear List, > > What is the way in R to plot a graph having date time (e.g. format > 12/31/2002 13:12) in the > x axis and numerical value (e.g. temperature) on the Y-axis ?If you have your dates as strings, you need to use strptime() to convert that into date-time objects first.> I could not get 'plot()' to do this as X axis values are non-numeric. > 'bwplot()' sorts the date > values and thereby changes the order of the dates and of Y. The date/time > values have to be > shown on the X-axis as tick values rotated by 90 deg. as there more than > 100 points. > > I appreciate your suggestions and hints. > > Thanks > sukhaswami > Lexicon Genetics > > >***************************************************************************> The contents of this communication are intended only for the addresseeand> may contain confidential and/or privileged material. If you are not the > intended recipient, please do not read, copy, use or disclose this > communication and notify the sender. Opinions, conclusions and other > information in this communication that do not relate to the official > business of my company shall be understood as neither given nor endorsedby> it. >***************************************************************************> > >-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.->.-.- 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 >_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._>._._-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._. _._ *************************************************************************** The contents of this communication are intended only for the addressee and may contain confidential and/or privileged material. If you are not the intended recipient, please do not read, copy, use or disclose this communication and notify the sender. Opinions, conclusions and other information in this communication that do not relate to the official business of my company shall be understood as neither given nor endorsed by it. *************************************************************************** -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>>>>> "Malladi," == Malladi, Sukhaswami <smalladi at lexgen.com> writes:> Dear List, What is the way in R to plot a graph having date > time (e.g. format 12/31/2002 13:12) in the x axis and > numerical value (e.g. temperature) on the Y-axis ? I tend to use chron for that sort of thing. Mike> dfdate time temp 1 2002/08/09 12:15:00 98 2 2002/08/09 13:15:00 95 3 2002/08/09 14:15:00 94 4 2002/08/08 15:15:00 90 5 2002/08/08 16:15:00 88 6 2002/08/08 17:15:00 80 7 2002/08/08 18:15:00 71 8 2002/08/08 19:15:00 76> library(chron) > df$datetime <- chron(dates=as.character(df$date),times=df$time,format=c('y/m/d', 'h:m:s')) # date and time> df$dates <- dates(df$datetime) # just the dates, with no time > df$times <- times(df$time) # just the times, independent of date > > dfdate time temp datetime dates times 1 2002/08/09 12:15:00 98 (02/08/09 12:15:00) 08/09/02 12:15:00 2 2002/08/09 13:15:00 95 (02/08/09 13:15:00) 08/09/02 13:15:00 3 2002/08/09 14:15:00 94 (02/08/09 14:15:00) 08/09/02 14:15:00 4 2002/08/08 15:15:00 90 (02/08/08 15:15:00) 08/08/02 15:15:00 5 2002/08/08 16:15:00 88 (02/08/08 16:15:00) 08/08/02 16:15:00 6 2002/08/08 17:15:00 80 (02/08/08 17:15:00) 08/08/02 17:15:00 7 2002/08/08 18:15:00 71 (02/08/08 18:15:00) 08/08/02 18:15:00 8 2002/08/08 19:15:00 76 (02/08/08 19:15:00) 08/08/02 19:15:00> > plot(temp ~ date, data=df) > plot(temp ~ time, data=df) > plot(temp ~ datetime, data=df) > plot(temp ~ dates, data=df) > plot(temp ~ times, data=df)-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._