[R] query pertains to dates

Gabor Grothendieck ggrothendieck at gmail.com
Mon Apr 3 20:11:31 CEST 2006


Try this:

dd <- as.Date(paste(REAL), "%Y%m%d")
format(dd, "%m/%d/%Y")

and read the Help Desk article in R News 4/1.


On 4/3/06, Amogh Deshpande <amogh at math.iisc.ernet.in> wrote:
>
>
> Hello,
>
> This query pertains to manipulation of dates in R. I am new to R and
> working on a time series data.
> I use the commands,
>
> REAL<-19920101 (say) # 01/01/1992
>
> year<-floor(as.integer(REAL/10000))
> year
> [1] 1992
>
> tmp<-as.integer(REAL)-year*10000
> tmp
> [1] 101
>
> month<-floor(tmp/100)
> day<-tmp-month*100
>
> month
> [1] 1
> day
> [1] 1
>
> tmp.julian<- julian(month, day, year)
>  tmp.julian
> [1] 8035
>
> dates(tmp.julian)
> 01/01/92
>
> I wish to have the output as 01/01/1992 and not 01/01/92 ,but i am
> unsuccessful and request your help.
>
>
> Thanking You.
> Regards
> Amogh
>
>
>
> *************************************************
> "If there is a problem to be solved, seek statistical advice instead of
> appointing a committee of experts. Statistics can throw more light than
> the collective wisdom of the articulate few."
>                          --Dr.C.R.Rao
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list