Hi there, In the following code snippet, # a <- strptime("121114 0510", "%m%d%y %H%M") b <- data.frame(date = a, res = 1:5) class(a) class(b[1,1]) # I am wondering why the class of a and b[1,1] are not the same. How to make the class of a and b[1,1] to be same? I would really appreciate you for any suggestions. Best regards, Jinsong
Jinsong Zhao <jszhao <at> yeah.net> writes:> In the following code snippet, > # > a <- strptime("121114 0510", "%m%d%y %H%M") > b <- data.frame(date = a, res = 1:5) > class(a) > class(b[1,1]) > # > I am wondering why the class of a and b[1,1] are not the same. > > How to make the class of a and b[1,1] to be same?How about a <- as.POSIXct(strptime(...)) ? (See ?POSIXct)
On 2015/1/5 17:28, Ben Bolker wrote:> Jinsong Zhao <jszhao <at> yeah.net> writes: > > >> In the following code snippet, >> # >> a <- strptime("121114 0510", "%m%d%y %H%M") >> b <- data.frame(date = a, res = 1:5) >> class(a) >> class(b[1,1]) >> # >> I am wondering why the class of a and b[1,1] are not the same. >> >> How to make the class of a and b[1,1] to be same? > > How about > > a <- as.POSIXct(strptime(...)) > > ? (See ?POSIXct)Thanks a lot. I have used as.POSIXct(...). I am wondering why the class of a and b[1,1] are not the same. Best, Jinsong