1. Please read the last line on every message to r-help and in particular
the part about providing reproducible code when you post.
2. Your third argument to apply is wrong. sharpe is a function but
sharpe(...whatever...) is not. Suggest you carefully review the
examples on the ?apply page if the difference is not clear.
On Dec 30, 2007 9:58 AM, Bernd Dittmann <herrdittmann at yahoo.co.uk>
wrote:> Hi R users,
>
> could anyone guide me in the right direction reg. the column-wise
> application of a function on a zoo dataframe.
>
> The tseries function sharpe() can only be applied to a univariate time
> series. Suppose you have merged the returns of two assets with
> get.hist.quote(), i.e.
>
> set <- merge(log(ibm), log(ge))
>
> is it possible to apply the function sharpe(), in this case with the
> argument
>
> scale=sqrt(52)
>
> since I am using weekly close prices
>
> to the dataset "set" column per column?
>
> I tried apply() with no result:
>
> > apply(set, 2, sharpe(set, scale=sqrt(52)))
> Fehler in sharpe(zz) : x is not a vector or univariate time series
>
> In the case of two securities, I could easily do it by hand, but for say
> 100 or even 500, I am looking for an automated solution.
>
>
> Many thanks in advance!
>
> Bernd
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>