[R] Datetime conversion

jim holtman jholtman at gmail.com
Fri Sep 18 14:07:18 CEST 2009


Your problem is that 'strptime' returns an object of POSIXlt type
which is 9 elements; what you what is: ( you need a POSIXct type)

dt$new<-as.POSIXct(strptime(as.character(dt$datetime),"%d%b%Y"))

On Fri, Sep 18, 2009 at 6:26 AM, premmad <mtechprem at gmail.com> wrote:
>
> It works but what i need is the result also as a column .
> I tried using the following code .
> dt$new<-strptime(as.character(dt$datetime),"%d%b%Y.
> It shows the following error
>
> Error in `$<-.data.frame`(`*tmp*`, "Sa_dt", value = list(sec = c(0, 0,  :
>  replacement has 9 rows, data has 14.
>
> Please help me to solve this
> --
> View this message in context: http://www.nabble.com/Datetime-conversion-tp25503138p25506438.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?




More information about the R-help mailing list