EVOLUTION-MANAGER
Edit File: addPanel.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: Add a panel to an existing xts plot</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 addPanel {xts}"><tr><td>addPanel {xts}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add a panel to an existing xts plot</h2> <h3>Description</h3> <p>Apply a function to the data of an existing xts plot object and plot the result. <code>FUN</code> should have arguments <code>x</code> or <code>R</code> for the data of the existing xts plot object to be passed to. All other additional arguments for <code>FUN</code> are passed through .... </p> <h3>Usage</h3> <pre> addPanel(FUN, main = "", on = NA, type = "l", col = NULL, lty = 1, lwd = 1, pch = 1, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>FUN</code></td> <td> <p>an xts object to plot.</p> </td></tr> <tr valign="top"><td><code>main</code></td> <td> <p>main title for a new panel if drawn.</p> </td></tr> <tr valign="top"><td><code>on</code></td> <td> <p>panel number to draw on. A new panel will be drawn if <code>on=NA</code>.</p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p>the type of plot to be drawn, same as in <code><a href="../../graphics/html/plot.html">plot</a></code>.</p> </td></tr> <tr valign="top"><td><code>col</code></td> <td> <p>color palette to use, set by default to rational choices.</p> </td></tr> <tr valign="top"><td><code>lty</code></td> <td> <p>set the line type, same as in <code><a href="../../graphics/html/par.html">par</a></code>.</p> </td></tr> <tr valign="top"><td><code>lwd</code></td> <td> <p>set the line width, same as in <code><a href="../../graphics/html/par.html">par</a></code>.</p> </td></tr> <tr valign="top"><td><code>pch</code></td> <td> <p>the type of plot to be drawn, same as in <code><a href="../../graphics/html/par.html">par</a></code>.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>additional named arguments passed through to <code>FUN</code> and any other graphical passthrough parameters.</p> </td></tr> </table> <h3>Author(s)</h3> <p>Ross Bennett </p> <h3>Examples</h3> <pre> library(xts) data(sample_matrix) sample.xts <- as.xts(sample_matrix) calcReturns <- function(price, method = c("discrete", "log")){ px <- try.xts(price) method <- match.arg(method)[1L] returns <- switch(method, simple = , discrete = px / lag(px) - 1, compound = , log = diff(log(px))) reclass(returns, px) } # plot the Close plot(sample.xts[,"Close"]) # calculate returns addPanel(calcReturns, method="discrete", type="h") # Add simple moving average to panel 1 addPanel(rollmean, k=20, on=1) addPanel(rollmean, k=40, col="blue", on=1) </pre> <hr /><div style="text-align: center;">[Package <em>xts</em> version 0.12.2 <a href="00Index.html">Index</a>]</div> </body></html>