Re: [R] Converting a dataframe column from string to datetime

2010-10-04 Thread raje...@cse.iitm.ac.in
ok..thanks - Original Message - From: Don MacQueen macque...@llnl.gov To: raje...@cse.iitm.ac.in, r-help r-help@r-project.org 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

[R] Converting a dataframe column from string to datetime

2010-10-01 Thread raje...@cse.iitm.ac.in
Hi, I have a dataframe column of the form 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) I need to convert this to datetime form. I did the following.. lapply(v,function(x){strptime(x, %a %b %d %H:%M:%OS %Y)})

Re: [R] Converting a dataframe column from string to datetime

2010-10-01 Thread Arun.stat
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

Re: [R] Converting a dataframe column from string to datetime

2010-10-01 Thread jim holtman
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-02-05 20:00:02 EST

Re: [R] Converting a dataframe column from string to datetime

2010-10-01 Thread MacQueen, Don
You’re 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”