[R] Continuasly Compunded Returns with quantmod-data

David Winsemius dwinsemius at comcast.net
Mon Nov 21 18:50:41 CET 2011


On Nov 21, 2011, at 11:58 AM, R. Michael Weylandt wrote:

> 1) It's sort of a cheap trick, but this works flexibly (i.e., you can
> put in func(SPY) or func("SPY") and get the same output):
>
> func <- function(y){
>    if(!require(quantmod)) stop("You need the quantmod package.")
>    chartSeries(get(getSymbols(as.character(substitute(y)), from =
> "2011-11-01")))
> }
>
> 2) coredata()
>
> Michael
>
> On Mon, Nov 21, 2011 at 10:42 AM, barb <mainzel89 at hotmail.com> wrote:
>> Many Thanks - Also for the link!
>> It works nice!

Alas the passing of the adverb. We loved her well. She will be missed.

>>
>> If i have further question, can i post them here or should i open a  
>> new
>> thread?

Please do not extend threads beyond the topics reasonably covered by  
their subject lines.

(And DO read the Posting Guide where this and many other questions  
have been addressed.)

>> 1)
>> If i want the following to make a function:
>> I do have to convert it, but i can´t get rid of these " " (brackets).
>>
>> func<-function(y) {
>> library(quantmod)
>> getSymbols("y",from="2011-11-01")
>> chartSeries(y)
>> }
>>
>> func(MSFT)
>>
>> 2) How i can get rid of the time dates and get a simple vector?

?xts

As you read the help pages, (you do read help pages, plural, right?)   
you should have found that coredata() returns the "interior" of xts  
objects.  index() and coredata() are described on the first reference  
from help(xts) to package zoo (which doesn't have a working hyperlink  
on my current version) so go to ....

?zoo

# one is expected to follow references from help pages ....as well as  
read all of the pages.

-- 
David.

>>
>>           GOOG.Open
>> 2011-11-01    580.10
>> 2011-11-02    584.90
>> 2011-11-03    587.00
>> 2011-11-04    593.50
>> 2011-11-07    593.32
>> 2011-11-08    609.00
>> 2011-11-09    604.26
>> 2011-11-10    605.93
>> 2011-11-11    601.30
>> 2011-11-14    608.00
>> 2011-11-15    612.80
>> 2011-11-16    612.08
>> 2011-11-17    610.05
>> 2011-11-18    602.00

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list