EVOLUTION-MANAGER
Edit File: nafill.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: Fill missing values</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 nafill {data.table}"><tr><td>nafill {data.table}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Fill missing values</h2> <h3>Description</h3> <p>Fast fill missing values using constant value, <em>last observation carried forward</em> or <em>next observation carried backward</em>. </p> <h3>Usage</h3> <pre> nafill(x, type=c("const","locf","nocb"), fill=NA, nan=NA) setnafill(x, type=c("const","locf","nocb"), fill=NA, nan=NA, cols=seq_along(x)) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p> vector, list, data.frame or data.table of numeric columns. </p> </td></tr> <tr valign="top"><td><code>type</code></td> <td> <p> character, one of <em>"const"</em>, <em>"locf"</em> or <em>"nocb"</em>. Defaults to <code>"const"</code>. </p> </td></tr> <tr valign="top"><td><code>fill</code></td> <td> <p> numeric or integer, value to be used to fill when <code>type=="const"</code>. </p> </td></tr> <tr valign="top"><td><code>nan</code></td> <td> <p> (numeric <code>x</code> only) Either <code>NaN</code> or <code>NA</code>; if the former, <code>NaN</code> is treated as distinct from <code>NA</code>, otherwise, they are treated the same during replacement? </p> </td></tr> <tr valign="top"><td><code>cols</code></td> <td> <p> numeric or character vector specifying columns to be updated. </p> </td></tr> </table> <h3>Details</h3> <p>Only <em>double</em> and <em>integer</em> data types are currently supported. </p> <p>Note that both <code>nafill</code> and <code>setnafill</code> provide some verbose output when <code>getOption('datatable.verbose')</code> is <code>TRUE</code>. </p> <h3>Value</h3> <p>A list except when the input is a <code>vector</code> in which case a <code>vector</code> is returned. For <code>setnafill</code> the input argument is returned, updated by reference. </p> <h3>See Also</h3> <p><code><a href="shift.html">shift</a></code>, <code><a href="data.table.html">data.table</a></code> </p> <h3>Examples</h3> <pre> x = 1:10 x[c(1:2, 5:6, 9:10)] = NA nafill(x, "locf") dt = data.table(v1=x, v2=shift(x)/2, v3=shift(x, -1L)/2) nafill(dt, "nocb") setnafill(dt, "locf", cols=c("v2","v3")) dt </pre> <hr /><div style="text-align: center;">[Package <em>data.table</em> version 1.14.4 <a href="00Index.html">Index</a>]</div> </body></html>