[R] How to use as.Date (or something else) with "31-Jul-2010 23:59:00"

Eduardo M. A. M.Mendes emammendes at gmail.com
Fri Jul 29 00:54:41 CEST 2011


Many thanks.

Sorry for not replying earlier but I have followed advice and read as much
documentation as I could.

I managed to get a zoo object the way I want

dadoszoo : 'zoo' series from 2010-06-27 to 2010-08-05
  Data: num [1:56161, 1:14] 74 74.2 74.2 74.1 73.9 ...
  Index:  POSIXct[1:56161], format: "2010-06-27 00:00:00" "2010-06-27
00:01:00" ...

I did not manage to get  plot.zoo to give x-axis a nice format (I only got
Jun 30 Jul10 Jul 20 Jul 30).  I guess the way to change it is the
documentation too but I am yet to find it.

Many thanks


-----Original Message-----
From: Gabor Grothendieck [mailto:ggrothendieck at gmail.com] 
Sent: Tuesday, July 26, 2011 8:31 PM
To: Eduardo Mendes
Cc: r-help at r-project.org
Subject: Re: [R] How to use as.Date (or something else) with "31-Jul-2010

On Tue, Jul 26, 2011 at 7:18 PM, Eduardo Mendes <emammendes at gmail.com>
> Hello  again
> I do apologize for the previous email without any useful information 
> that can lead to an answer.  To those who felt offended by "to no 
> avail", I do apologize again.  I guess I will be always a newbie as 
> far as R is concerned.
> The date format was wrong and although I have tried to use different 
> formats I could not get the result I wanted.  So I went back to the 
> file and changed to a format that R can understand (Please understand 
> that R is very likely to have package that I might be unaware of).  
> Now all dates are
>> class(data$TempDate)
> [1] "POSIXct" "POSIXt"
>> data$TempDate[1:2]
> [1] "2010-06-27 00:00:00 BRT" "2010-06-27 00:01:00 BRT"
> If I issue the command as.Date(data$TempDate[2]), the information on 
> hour, minute and second is lost
> as.Date(data$TempDate[2])
> [1] "2010-06-27"
> If I use data$TempDate in a zoo object, I got the following msg
> some methods for "zoo" objects do not work if the index entries in
> are not unique
> If I issue plot(zoo object), the result is a mess since many values do 
> not have an unique entry (as expected).
> How can I use the information on data$TempDate to create unique 
> indexes for zoo objects and the like?

Read R News 4/1 and its references to find out about R's date time classes
and then read the 5 vignettes (PDF documents) that come with zoo for many

Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

More information about the R-help mailing list