EVOLUTION-MANAGER
Edit File: fcase.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: fcase</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 fcase {data.table}"><tr><td>fcase {data.table}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>fcase</h2> <h3>Description</h3> <p><code>fcase</code> is a fast implementation of SQL <code>CASE WHEN</code> statement for R. Conceptually, <code>fcase</code> is a nested version of <code><a href="fifelse.html">fifelse</a></code> (with smarter implementation than manual nesting). It is comparable to <code>dplyr::case_when</code> and supports <code>bit64</code>'s <code>integer64</code> and <code>nanotime</code> classes. </p> <h3>Usage</h3> <pre> fcase(..., default=NA) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p> A sequence consisting of logical condition (<code>when</code>)-resulting value (<code>value</code>) <em>pairs</em> in the following order <code>when1, value1, when2, value2, ..., whenN, valueN</code>. Logical conditions <code>when1, when2, ..., whenN</code> must all have the same length, type and attributes. Each <code>value</code> may either share length with <code>when</code> or be length 1. Please see Examples section for further details.</p> </td></tr> <tr valign="top"><td><code>default</code></td> <td> <p> Default return value, <code>NA</code> by default, for when all of the logical conditions <code>when1, when2, ..., whenN</code> are <code>FALSE</code> or missing for some entries. </p> </td></tr> </table> <h3>Value</h3> <p>Vector with the same length as the logical conditions (<code>when</code>) in <code>...</code>, filled with the corresponding values (<code>value</code>) from <code>...</code>, or eventually <code>default</code>. Attributes of output values <code>value1, value2, ...valueN</code> in <code>...</code> are preserved. </p> <h3>See Also</h3> <p><code><a href="fifelse.html">fifelse</a></code> </p> <h3>Examples</h3> <pre> x = 1:10 fcase( x < 5L, 1L, x > 5L, 3L ) fcase( x < 5L, 1L:10L, x > 5L, 3L:12L ) # Lazy evaluation example fcase( x < 5L, 1L, x >= 5L, 3L, x == 5L, stop("provided value is an unexpected one!") ) # fcase preserves attributes, example with dates fcase( x < 5L, as.Date("2019-10-11"), x > 5L, as.Date("2019-10-14") ) # fcase example with factor; note the matching levels fcase( x < 5L, factor("a", levels=letters[1:3]), x > 5L, factor("b", levels=letters[1:3]) ) # Example of using the 'default' argument fcase( x < 5L, 1L, x > 5L, 3L, default = 5L ) </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>