[R] Problem with Dates :-(

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Apr 2 12:23:09 CEST 2009



Suresh_FSFM wrote:
> Dear R users, 
> I know, the question is bit old one. :-(
> 
> Ok. I have a table with say three columns and 70 rows.
> The second column has dates in format dd.mm.yy (i.e. 01.10.07 indicating
> record for October 1, 2007).
> I read the text file, containing the records. Now, I want to find out the
> weekday for each date.
> However, I cannot do so.
> 
> 1)
> If I type result[1,"Date"] to see the Date in the first row, I get following
> output:
> 70 Levels: 01.10.07 01.11.07 02.10.07 02.12.07.. and so on.
> 
> 2)
> If I use any functions related to Date or time, I get the message: character
> string is not in a standard unambigious format.
> :-(
> 
> I can understand that first I have to "convert" the existing date format to
> such a format that R "recognizes" as date format. However, I am not able to
> do so.
> 
> I did try to use format.Date() and as.Date() functions. However, no success. 
> I am making some silly mistake. 
> Please help.


If you want Date rather than some posic format, use

newDate <- as.Date(result[,"Date"], "%d.%m.%y"))

Uew Ligges




> 
> Thank you.
> 
> Best Regards,
> Suresh
> 
> 
>




More information about the R-help mailing list