[R-SIG-Mac] dates in R

David Winsemius dwinsemius at comcast.net
Sat Oct 23 23:34:50 CEST 2010


On Oct 23, 2010, at 2:09 PM, Turner Rolf wrote:

>
>
> sirmeelo at gmail.com [sirmeelo at gmail.com] wrote:
>
> Hi list,
>
> I am having trouble getting R to read and display dates correctly.  
> My dates
> are in the form of day (no space) month (no space) year, for  
> example: 250706
> and sometimes 50906.
>
> Any guidance would be appreciated...Thanks.
>
> (1) This question has nothing to do with Mac computers.  It should  
> have been sent to r-help.
>
> (2) The problem seems to me to be the inconsistency in the number of  
> digits representing
> "day",  To remedy this, paste on a zero and then remove redundant  
> zeroes:
>
> foo <- function(x) {
>              x <- paste(0,x,sep="")
>              x <- substr(x,nchar(x)-5,nchar(x))
>              strptime(x,format="%d%m%y")
> }
>
> x <- c(250706,50906)
> foo(x)
> [1] "2006-07-25" "2006-09-05"

All true. I have had to do steps equivalent to this, but learned from  
my experience. I now use colClasses to import dates as "character"  
rather than numeric.

-- 
David.
>
> HTH.
>
>     cheers,
>
>           Rolf Turner
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac



More information about the R-SIG-Mac mailing list