Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

range_sortna

Prepare for sorting and get range, number of NAs and unsortedness


Description

In one pass over the vector NAs are treated according to parameter na.last exactly like sort does, the range, number of NAs and unsortedness is determined.

Usage

range_sortna(x, decreasing = FALSE, na.last = NA)

Arguments

x

an integer vector

decreasing

(currently only FALSE is supported)

na.last

NA removes NAs, FALSE puts NAs at the beginning, TRUE puts NAs at the end

Value

an integer vector with NAs are treated and an attribute range_na with four elements

1

min integer

2

max integer

3

number of NAs

3

0 for sorted vector and 1 for is.unsorted

See Also

Examples

range_sortna(c(0L,1L,NA,2L))
range_sortna(c(2L,NA,1L,0L))
range_sortna(c(0L,1L,NA,2L), na.last=TRUE)
range_sortna(c(2L,NA,1L,0L), na.last=TRUE)
range_sortna(c(0L,1L,NA,2L), na.last=FALSE)
range_sortna(c(2L,NA,1L,0L), na.last=FALSE)

bit

Classes and Methods for Fast Memory-Efficient Boolean Selections

v4.0.4
GPL-2 | GPL-3
Authors
Jens Oehlschlägel [aut, cre], Brian Ripley [ctb]
Initial release
2020-08-03

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.