How can I change the format of this dates in R -
i have dates in r:
> head(mydates) [1] "2007-01-01" "2007-01-02" "2007-01-03" "2007-01-04" "2007-01-05" "2007-01-08" > class(mydates) [1] "date"
and want change format
> head(targetdates) [1] "2007-01-01 gmt" "2007-01-02 gmt" "2007-01-03 gmt" "2007-01-04 gmt" [5] "2007-01-05 gmt" "2007-01-08 gmt" > class(targetdates) [1] "posixct" "posixt"
how can (in r)?
thanks
you can use as.posixct
mydates ## [1] "2007-01-01" "2007-01-02" "2007-01-03" "2007-01-04" "2007-01-05" "2007-01-08" class(mydates) ## [1] "date" sys.setenv(tz = "gmt") #necessary of want dates printed in gmt as.posixct(mydates) ## [1] "2007-01-01 gmt" "2007-01-02 gmt" "2007-01-03 gmt" "2007-01-04 gmt" "2007-01-05 gmt" "2007-01-08 gmt"
also read ?posixct
Comments
Post a Comment