[R] How to combine Date and time in one column
Uwe Ligges
ligges at statistik.tu-dortmund.de
Mon Nov 22 09:07:18 CET 2010
On 22.11.2010 08:24, rnick wrote:
>
> Hello everyone,
>
> I am trying to built an xts object and i have run into some problems on the
> data handling. I would really appreciate if someone could help me with the
> following:
>
> 1) I have a OHLC dataset with Time and date in different columns. How could
> i combine date and time in one column in order to pass on the new column to
> xts? I have use cbind and data.frame before but i did not manage to yield
> any good results as the formating of the file changes.
>
> Date Time O H L C
> 1/2/2005 17:05 1.3546 1.3553 1.3546 1.35495
> 1/2/2005 17:10 1.3553 1.3556 1.3549 1.35525
> 1/2/2005 17:15 1.3556 1.35565 1.35515 1.3553
> 1/2/2005 17:25 1.355 1.3556 1.355 1.3555
> 1/2/2005 17:30 1.3556 1.3564 1.35535 1.3563
dat$DateTime <- strptime(paste(dat$Date, dat$Time), "%d/%m/%Y %H:%M")
Uwe Ligges
> 2) It is not clear to me what is the best way to construct the .xts object?
> Should i use only the Date&time to index or should i also combine it with
> the rest of the variables?
>
> Thanks in advance,
>
> N
More information about the R-help
mailing list