EVOLUTION-MANAGER
Edit File: vec_order.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: Order and sort vectors</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 vec_order {vctrs}"><tr><td>vec_order {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Order and sort vectors</h2> <h3>Description</h3> <p>Order and sort vectors </p> <h3>Usage</h3> <pre> vec_order( x, ..., direction = c("asc", "desc"), na_value = c("largest", "smallest") ) vec_sort( x, ..., direction = c("asc", "desc"), na_value = c("largest", "smallest") ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vector</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>These dots are for future extensions and must be empty.</p> </td></tr> <tr valign="top"><td><code>direction</code></td> <td> <p>Direction to sort in. Defaults to <code>asc</code>ending.</p> </td></tr> <tr valign="top"><td><code>na_value</code></td> <td> <p>Should <code>NA</code>s be treated as the largest or smallest values?</p> </td></tr> </table> <h3>Value</h3> <ul> <li> <p><code>vec_order()</code> an integer vector the same size as <code>x</code>. </p> </li> <li> <p><code>vec_sort()</code> a vector with the same size and type as <code>x</code>. </p> </li></ul> <h3>Differences with <code>order()</code></h3> <p>Unlike the <code>na.last</code> argument of <code>order()</code> which decides the positions of missing values irrespective of the <code>decreasing</code> argument, the <code>na_value</code> argument of <code>vec_order()</code> interacts with <code>direction</code>. If missing values are considered the largest value, they will appear last in ascending order, and first in descending order. </p> <h3>Dependencies of <code>vec_order()</code></h3> <ul> <li> <p><code><a href="vec_proxy_compare.html">vec_proxy_order()</a></code> </p> </li></ul> <h3>Dependencies of <code>vec_sort()</code></h3> <ul> <li> <p><code><a href="vec_proxy_compare.html">vec_proxy_order()</a></code> </p> </li> <li> <p><code><a href="vec_order.html">vec_order()</a></code> </p> </li> <li> <p><code><a href="vec_slice.html">vec_slice()</a></code> </p> </li></ul> <h3>Examples</h3> <pre> x <- round(c(runif(9), NA), 3) vec_order(x) vec_sort(x) vec_sort(x, direction = "desc") # Can also handle data frames df <- data.frame(g = sample(2, 10, replace = TRUE), x = x) vec_order(df) vec_sort(df) vec_sort(df, direction = "desc") # Missing values interpreted as largest values are last when # in increasing order: vec_order(c(1, NA), na_value = "largest", direction = "asc") vec_order(c(1, NA), na_value = "largest", direction = "desc") </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>