ok..thanks
- Original Message -
From: Don MacQueen
To: raje...@cse.iitm.ac.in, r-help
Sent: Fri, 01 Oct 2010 20:51:06 +0530 (IST)
Subject: Re: [R] Converting a dataframe column from string to datetime
Youâre working too hard. Use this:
tms <- as.POSIXct(strptime(v, "%a
Youre working too hard. Use this:
tms <- as.POSIXct(strptime(v, "%a %b %d %H:%M:%OS %Y"))
Take note of the fact that there are two types of datetime objects: POSIXct
and POSIXlt.
Your unlist() gave what seemed a strange result because you used on an lt
object. Had you given it a ct ob
I think you want to use as.POSIXct to get the date value:
> v<-c("Fri Feb 05 20:00:01.43000 2010","Fri Feb 05 20:00:02.274000 2010","Fri
> Feb 05 20:00:02.274000 2010","Fri Feb 05 20:00:06.34000 2010")
> x <- as.POSIXct(v, format= "%a %b %d %H:%M:%OS %Y")
> x
[1] "2010-02-05 20:00:01 EST" "2010-0
Is it okay with you?
Reduce("rbind", lapply(lapply(v,function(x){strptime(x, "%a %b %d %H:%M:%OS
%Y")}), as.character))
--
View this message in context:
http://r.789695.n4.nabble.com/Converting-a-dataframe-column-from-string-to-datetime-tp2853709p2869793.html
Sent from the R help mailing list a
4 matches
Mail list logo