quantmod package using "convert.time.series" function
Hi Tom, The function is internal to quantmod, as such undocumented and ugly :)
quantmod:::convert.time.series
function (fr, return.class)
{
if ("quantmod.OHLC" %in% return.class) {
class(fr) <- c("quantmod.OHLC", "zoo")
return(fr)
}
else if ("xts" %in% return.class) {
return(fr)
}
if ("zoo" %in% return.class) {
return(as.zoo(fr))
}
else if ("ts" %in% return.class) {
fr <- as.ts(fr)
return(fr)
}
else if ("data.frame" %in% return.class) {
fr <- as.data.frame(fr)
return(fr)
}
else if ("matrix" %in% return.class) {
fr <- as.data.frame(fr)
return(fr)
}
else if ("its" %in% return.class) {
if ("package:its" %in% search() || suppressMessages(require("its",
quietly = TRUE))) {
fr.dates <- as.POSIXct(as.character(index(fr)))
fr <- its::its(coredata(fr), fr.dates)
return(fr)
}
else {
warning(paste("'its' from package 'its' could not be loaded:",
" 'xts' class returned"))
}
}
else if ("timeSeries" %in% return.class) {
if ("package:fSeries" %in% search() ||
suppressMessages(require("fSeries",
quietly = TRUE))) {
fr <- timeSeries(coredata(fr), charvec = as.character(index(fr)))
return(fr)
}
else {
warning(paste("'timeSeries' from package 'fSeries' could
not be loaded:",
" 'xts' class returned"))
}
}
}
<environment: namespace:quantmod>
Much better conversion (though slightly different form) can be found in xts
?try.xts, reclass, and Reclass.
HTH,
Jeff
R/Finance 2009: Applied Finance with R
April 24 and 25th 2009, Chicago, IL, USA
http://www.RinFinance.com
On Mon, Mar 16, 2009 at 12:54 PM, Tom H <tom at limepepper.co.uk> wrote:
Hi, I was having a look at the quantmod function for getSymbols.MySQL, and it uses a "convert.time.series()" function. I had a search for a reference on it, but I can't find anything. What am I doing wrong?
?convert.time.series
No documentation for 'convert.time.series' in specified packages and libraries: you could try '??convert.time.series'
??convert.time.series
and nothing there as well, but the function executes, so something must understand what it is...; ? ? ? ? ? ? ? ? ? ? ? ?fr <- convert.time.series(fr = fr, return.class = return.class) Any ideas? Cheers, T
_______________________________________________ R-SIG-Finance at stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. -- If you want to post, subscribe first.
Jeffrey Ryan jeffrey.ryan at insightalgo.com ia: insight algorithmics www.insightalgo.com