[R] apply in zoo

From: Bernd Dittmann <herrdittmann_at_yahoo.co.uk>
Date: Sun, 30 Dec 2007 14:58:41 +0000

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


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!


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. Received on Sun 30 Dec 2007 - 15:04:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 30 Dec 2007 - 17:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.