Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

trailingFUN

apply a function over a configurable trailing period


Description

this function is primarily designed for use with portfolio functions passing 'x' or 'R' and weights, but may be usable for other things as well, see Example for a vector example.

Usage

trailingFUN(R, weights, n = 0, FUN, FUNargs = NULL, ...)

Arguments

R

an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns

weights

a vector of weights to test

n

numeric number of trailing periods

FUN

string describing the function to be called

FUNargs

list describing any additional arguments

...

any other passthru parameters

Details

called with e.g.

trailingFUN(seq(1:100), weights=NULL, n=12, FUN='mean',FUNargs=list())


PortfolioAnalytics

Portfolio Analysis, Including Numerical Methods for Optimization of Portfolios

v1.1.0
GPL-2 | GPL-3
Authors
Brian G. Peterson [cre, aut, cph], Peter Carl [aut, cph], Kris Boudt [ctb, cph], Ross Bennett [ctb, cph], Hezky Varon [ctb], Guy Yollin [ctb], R. Douglas Martin [ctb]
Initial release
2018-05-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.