[R-SIG-Finance] 2 time/date columns to one

Costas Vorlow costas.vorlow at gmail.com
Fri May 25 19:00:46 CEST 2012


Hi,

I am getting:

Error in as.POSIXlt.character(x, tz, ...) :
  character string is not in a standard unambiguous format

I am also using:

Sys.setenv(TZ="GMT")

just in case.

Any thoughts?

On 25 May 2012 19:49, R. Michael Weylandt <michael.weylandt at gmail.com> wrote:
> Use xts (always use xts!) and do something like this:
>
> Suppose your data is in three columns called "dat"
>
> xts(dat[,3], as.POSIXct(paste(dat[,1], dat[,2], format = "%m/%d/%Y %H%M"))
>
> This will make an xts of your data taking the third column as the
> data-bit and using the first two to make a POSIXct (time) object
> converting them using the format specification.
>
> Hope that helps,
>
> Michael
>
> On Fri, May 25, 2012 at 12:35 PM, Costas Vorlow <costas.vorlow at gmail.com> wrote:
>> Hello,
>>
>> I have trouble connecting times with dates to create a "proper" time sequence:
>>
>> 5/22/2012       1640    318295
>> 5/22/2012       1641    432517
>> 5/22/2012       1642    328233
>> 5/22/2012       1643    444692
>> 5/22/2012       1644    217440
>> 5/22/2012       1645    650593
>> 5/22/2012       1646    207366
>> 5/22/2012       1647    334881
>> 5/22/2012       1648    133929
>> 5/22/2012       1649    267117
>> 5/22/2012       1650    179423
>> 5/22/2012       1651    259668
>> 5/22/2012       1652    341661
>>
>>
>> The table above is a time sequence. The 1st column on the left is the
>> date and the next column contains the time of day (1640= 4:40pm). The
>> 3rd column is the price of a variable at that point in time. Hence, I
>> want to convert the above table to a time series variable (xts, zoo,
>> etc) of some sort. Any pointer extremely welcome ( I know this is a
>> lame question)...
>>
>> Many thanks in advance,
>>
>> Costas
>>
>> --
>>
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>> |c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
>> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
>>
>> _______________________________________________
>> R-SIG-Finance at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> -- Subscriber-posting only. If you want to post, subscribe first.
>> -- Also note that this is not the r-help list where general R questions should go.



-- 

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+



More information about the R-SIG-Finance mailing list