Dear Rusers, I have some data in .csv file like "2004-8-1" and "2004-10-1", and i need to convert them into days from the origin (January 1, 1960). I have tried the function date.mmddyyyy(), but cannot get it. Anybody can show me how to handle the date data? Thanks very much! My dataset like: time 2004-8-1 2004-10-1 2001-9-1 2002-9-1 -- With Kind Regards, oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [***********************************************************************] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:epistat@gmail.com Website: www.statABC.com [***********************************************************************] oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [[alternative HTML version deleted]]
Take a look at the "chron" package...> as.chron("2004-8-1",format=c(dates="y-m-d")) - as.chron("1960-1-1",format=c(dates="y-m-d"))Time in days: [1] 16284 On 9/13/07, zhijie zhang <epistat@gmail.com> wrote:> > Dear Rusers, > I have some data in .csv file like "2004-8-1" and "2004-10-1", and > i need > to convert them into days from the origin (January 1, 1960). > I have tried the function date.mmddyyyy(), but cannot get it. Anybody can > show me how to handle the date data? > Thanks very much! > > My dataset like: > time > 2004-8-1 > 2004-10-1 > 2001-9-1 > 2002-9-1 > > > -- > With Kind Regards, > > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > [***********************************************************************] > Zhi Jie,Zhang ,PHD > Tel:86-21-54237149 > Dept. of Epidemiology,School of Public Health,Fudan University > Address:No. 138 Yi Xue Yuan Road,Shanghai,China > Postcode:200032 > Email:epistat@gmail.com > Website: www.statABC.com > [***********************************************************************] > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
dts <- c("2004-8-1","2004-10-1","2001-9-1") strptime(dts,"%Y-%m-%d") julian(strptime(dts,"%Y-%m-%d"))> -----Original Message----- > From: r-help-bounces at r-project.org > [mailto:r-help-bounces at r-project.org] On Behalf Of zhijie zhang > Sent: Thursday, September 13, 2007 8:19 AM > To: R-help at stat.math.ethz.ch > Subject: [R] handle dates in R? > > Dear Rusers, > I have some data in .csv file like "2004-8-1" and > "2004-10-1", and i need to convert them into days from the > origin (January 1, 1960). > I have tried the function date.mmddyyyy(), but cannot get it. > Anybody can show me how to handle the date data? > Thanks very much! > > My dataset like: > time > 2004-8-1 > 2004-10-1 > 2001-9-1 > 2002-9-1 > > > -- > With Kind Regards, > > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > [************************************************************* > **********] > Zhi Jie,Zhang ,PHD > Tel:86-21-54237149 > Dept. of Epidemiology,School of Public Health,Fudan > University Address:No. 138 Yi Xue Yuan Road,Shanghai,China > Postcode:200032 > Email:epistat at gmail.com > Website: www.statABC.com > [************************************************************* > **********] > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >This e-mail message is intended only for the named recipient(s) above. It may contain confidential information. If you are not the intended recipient you are hereby notified that any dissemination, distribution or copying of this e-mail and any attachment(s) is strictly prohibited. If you have received this e-mail in error, please immediately notify the sender by replying to this e-mail and delete the message and any attachment(s) from your system. Thank you.
Seemingly Similar Threads
- Generating series of distributions with the same skewness and different kurtosis or with same kurtosis and different skewness?
- Specify a correct formula in R for Piecewise Linear Functions?
- Anybody has ever met the problem to add a legend to a figure generated by image()?
- How to add legend for image()?
- Is there any good tools to facilitate us to create R functions?