EVOLUTION-MANAGER
Edit File: period.apply.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Apply Function Over Specified Interval</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for period.apply {xts}"><tr><td>period.apply {xts}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Apply Function Over Specified Interval </h2> <h3>Description</h3> <p>Apply a specified function to data over a given interval, where the interval is taken to be the data from INDEX[k] to INDEX[k+1], for k=1:(length(INDEX)-1). </p> <h3>Usage</h3> <pre> period.apply(x, INDEX, FUN, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> data to apply FUN to </p> </td></tr> <tr valign="top"><td><code>INDEX</code></td> <td> <p> numeric vector specifying indexing </p> </td></tr> <tr valign="top"><td><code>FUN</code></td> <td> <p> an argument of type <code>function</code> </p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p> additional arguments for <code>FUN</code></p> </td></tr> </table> <h3>Details</h3> <p>Similar to the rest of the apply family, calculate a specified functions value given a shifting set of data values. The primary difference is that it is that <code>period.apply</code> applies a function to non-overlapping intervals along a vector. </p> <p>Useful for applying arbitrary functions over an entire data object by an aribirtary index, as when INDEX is the result of a call to breakpoints. </p> <h3>Value</h3> <p>A vector with length of INDEX minus 1 </p> <h3>Author(s)</h3> <p> Jeffrey A. Ryan </p> <h3>See Also</h3> <p><code><a href="endpoints.html">endpoints</a></code> <code><a href="apply.monthly.html">apply.monthly</a></code></p> <h3>Examples</h3> <pre> zoo.data <- zoo(rnorm(31)+10,as.Date(13514:13744,origin="1970-01-01")) ep <- endpoints(zoo.data,'weeks') period.apply(zoo.data, INDEX=ep, FUN=function(x) mean(x)) period.apply(zoo.data, INDEX=ep, FUN=mean) #same glue <- function(x) { paste(x,collapse='') } period.apply(letters,c(0,5,7,26),glue) </pre> <hr /><div style="text-align: center;">[Package <em>xts</em> version 0.12.2 <a href="00Index.html">Index</a>]</div> </body></html>