| To: | Kim Elmore <Kim.Elmore@noaa.gov> |
|---|---|
| Subject: | Re: Dates and Times in S-Plus |
| From: | David L Lorenz <lorenz@usgs.gov> |
| Date: | Fri, 6 Apr 2007 13:17:51 -0500 |
| Cc: | S-News <s-news@wubios.wustl.edu>, s-news-owner@lists.biostat.wustl.edu |
| In-reply-to: | <46167260.5020304@noaa.gov> |
|
Kim, There are a lot of thing to consider when making plots of date/time data, including getting ticks in the correct place and correct labels. We are trying to develop functions that will plot the data correctly and get nice ticks and correct labels. I don't have anything for hourly data right now, but when we do get a good product, those functions will be publically available. Here's basically the approach I would take: 1. For the GUI and command, I'd generate a data.frame that contains the ticks and labels I wanted. Use the timeSeq() function to generate ticks: > timeSeq("11/29/2007 14:15:00", by='hours', length.out=6, align.by=T, extend=T) [1] 11/29/2007 14:00:00.000 11/29/2007 15:00:00.000 11/29/2007 16:00:00.000 [4] 11/29/2007 17:00:00.000 11/29/2007 18:00:00.000 11/29/2007 19:00:00.000 Use the hms() function on those data to extract the hour and put that into another column for the labels. You can further format them any way you wish. 2. For the GUI plot, set the major ticks to use a column in a separate data set and choose the one you created in step one. Do the same for labels. 3. To subset the data, use something like: DateTime >= timeDate("11/29/2007 14:15:00") & DateTime <= timeDate("11/29/2007 18:15:00") in your subsetting _expression_, assuming that the date/time column name is DateTime. 4. For the command line version, I'd convert everything to double for the date/time axis, set the axis type to 'i' or 's' and not draw anything on that axis. Then go back and draw the axis, put in the ticks and labels. Good luck. Dave
I've never much worked with dates and times, but find that I must now do so. I'm doing some very basic EDA and using the GUI to generate some plots. When making plots using the GUI, how do I control the span of the date axis? I'm aware that S-Plus encodes the date in a manner similar to unix/linux, but I don't know how to define things like tic marks in terms of, say hours. For example, if I want a tic mark every hour, how do I declare that? Using command line plots, how would I subset the data such that I plotted only data between, say, 11/29/2007 14:15:00 and 11/29/2007 18:15:00? All data are currently in a data.frame and the data type for the dates column is timeDate. I'm using S-Plus 7.0.6 under Windows XP. Kim Elmore -------------------------------------------------------------------- This message was distributed by s-news@lists.biostat.wustl.edu. To unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with the BODY of the message: unsubscribe s-news |
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Dates and Times in S-Plus, Kim Elmore |
|---|---|
| Next by Date: | Re: Dates and Times in S-Plus, Eric Zivot |
| Previous by Thread: | Dates and Times in S-Plus, Kim Elmore |
| Next by Thread: | Re: Dates and Times in S-Plus, Eric Zivot |
| Indexes: | [Date] [Thread] [Top] [All Lists] |