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

Jeff Ryan jeff.a.ryan at gmail.com
Tue Dec 14 00:33:19 CET 2010


You can coerce back (assuming the data is coercible) using storage.mode<-

x <- xts(as.character(100), Sys.Date())
x
           [,1]
2010-12-13 "100"

storage.mode(x)
[1] "character"

storage.mode(x) <- "numeric"
storage.mode(x)
[1] "double"

x
           [,1]
2010-12-13  100

HTH
Jeff

On Mon, Dec 13, 2010 at 4:20 PM, Nick Torenvliet
<nick.torenvliet at gmail.com> 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.
>



-- 
Jeffrey Ryan
jeffrey.ryan at lemnica.com

www.lemnica.com



More information about the R-SIG-Finance mailing list