[R-SIG-Finance] xts / split time series issue

Brian G. Peterson brian at braverock.com
Mon Dec 13 23:39:59 CET 2010


We load historical data (as from CSV files), split() and then xts here.

Alternately, you can likely get a list of unique() symbols in your xts, 
and then loop through them and assign to a variable named for 'symbol', 
with something like

assign('ZUT',table[table$symbol=='ZUT',c('open','high','low','close','volume')])

Cheers,

   - Brian


On 12/13/2010 04:20 PM, Nick Torenvliet wrote:
> Hi all,
>
>> splitTable<- split(table, table$symbol)
>> zutTable<- xts(splitTable$ZUT[,-1],order.by
> =as.POSIXct(splitTable$ZUT[,1]))
>> zutTable<- zutTable[,-6]
>> zutTable
>             open    high    low     close   volume
> 2010-12-02 "16.46" "16.48" "16.45" "16.46" " 5567"
> 2010-12-03 "16.48" "16.48" "16.36" "16.39" "12062"
> 2010-12-06 "16.35" "16.40" "16.35" "16.40" " 7197"
> 2010-12-07 "16.41" "16.42" "16.35" "16.40" " 8316"
> 2010-12-08 "16.44" "16.44" "16.33" "16.34" "17637"
> 2010-12-09 "16.34" "16.35" "16.30" "16.35" " 4035"
> 2010-12-10 "16.33" "16.38" "16.33" "16.35" " 5646"
>> candleChart(zutTable)
> Error in na.omit.xts(x) : unsupported type
>
> Which is due to split which as advertised coerces the data to a
> character/string type.
>
> So I've tried a number of data type changes... and can't get the back to a
> numeric data type without frying the xts'ness of the data.
>
> Any suggestions?
>
> Nick
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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.


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list