Hi, I have a column of a dataframe which has time stamps like:> eh$t[1][1] 06/05/2005 01:15:25 and was wondering how to convert it to chron variable. Thanks a lot. Young.
On 7/13/05, Young Cho <iidn01@yahoo.com> wrote:> > Hi, > > I have a column of a dataframe which has time stamps > like: > > > eh$t[1] > [1] 06/05/2005 01:15:25 > > and was wondering how to convert it to chron variable. > Thanks a lot.Try this: # test data frame eh containing a factor variable t eh <- data.frame(t = c("06/05/2005 01:15:25", "06/07/2005 01:15:25")) # substring converts factor to character and extracts substring chron(dates = substring(eh$t, 1, 10), times = substring(eh$t, 12)) See ?chron for more info. There is an article on dates in R News 4/1 and although it does not specifically answer this question it may be useful with chron and also provides a reference to more chron info elsewhere. [[alternative HTML version deleted]]
[I had some emails problems so I am sending this again. Sorry if you get it twice.] On 7/13/05, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:> > > On 7/13/05, Young Cho <iidn01 at yahoo.com> wrote: > > Hi, > > > > I have a column of a dataframe which has time stamps > > like: > > > > > eh$t[1] > > [1] 06/05/2005 01:15:25 > > > > and was wondering how to convert it to chron variable. > > Thanks a lot. > > > > >Try this: # test data frame eh containing a factor variable t eh <- data.frame(t = c("06/05/2005 01:15:25", "06/07/2005 01:15:25")) # substring converts factor to character and extracts substring chron(dates = substring(eh$t, 1, 10), times = substring(eh$t, 12)) See ?chron for more info. There is an article on dates in R News 4/1 and although it does not specifically answer this question it may be useful with chron and also provides a reference to more chron info elsewhere.