[R] Getting objects from quantmod ticker list
R. Michael Weylandt
michael.weylandt at gmail.com
Wed Jul 11 22:09:01 CEST 2012
On Wed, Jul 11, 2012 at 3:08 PM, R. Michael Weylandt
<michael.weylandt at gmail.com> wrote:
> On Wed, Jul 11, 2012 at 3:07 PM, R. Michael Weylandt
> <michael.weylandt at gmail.com> wrote:
>> On Wed, Jul 11, 2012 at 1:49 PM, Cren <oscar.soppelsa at bancaakros.it> wrote:
>>> # One more question, Joshua: let instead of merging tickers
>>> # I would like to put prices from an OHLC object
>>> # in weekly format, then selecting just the close prices.
>>> # What would be a code to do it?
>>> # I guess:
>>> data = new.env()
>>> ticker.list <- c('SPY', 'TLT', 'GLD')
>>> getSymbols(ticker.list, env = data)
>>> X <- do.call(to.weekly, list(data))
>> I think you need
>> do.call(rbind, as.list(eapply(data, function(x) Cl(to.weekly(x)))))
> My apologies: that should be rbind()
> Also, you might want to re-attach names:
> names(X) <- ticker.list
>> Working from the inside out:
>> to.weekly -- go to weekly frequency
>> Cl -- take the close
>> eapply -- do this to each element of the data environment
>> as.list -- convert to list
>> do.call(cbind, ...) -- put them all together.
>> Though there may be something simpler.
>>> # or something like this, but it doesn't work.
>>> # What could I do?
>>> View this message in context: http://r.789695.n4.nabble.com/Getting-objects-from-quantmod-ticker-list-tp4635708p4636162.html
>>> Sent from the R help mailing list archive at Nabble.com.
>>> R-help at r-project.org mailing list
>>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help