is.sorted: Check Whether Vectors are Sorted

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/PCSmisc.R

Description

Check whether one or more vectors are sorted. In the case of more than one vector, the function checks if each vector is sorted within blocks of the preceeding vector(s).

Usage

1

Arguments

...

One or more atomic vectors, all of the same length.

Details

If called with a single argument x, this function simply returns !is.unsorted(x). If called with more than one argument, then order is used on all arguments, and the result is compared to 1:n where n is the common length of all the arguments.

Thus, in the multiple vector case, the ordering is defined by the nested structure of the vectors (See example).

Value

A logical.

Author(s)

Ben Rich <[email protected]>

See Also

is.unsorted order

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
require(nlme)
data(Phenobarb)
dat <- Phenobarb[1:56,]  # First 4 subjects
dat$id <- asID(dat$Subject)

attach(dat)

is.sorted(id)        # TRUE  - data are sorted by id
is.sorted(time)      # FALSE - data are NOT sorted by time
is.sorted(id, time)  # TRUE  - within id blocks, data are sorted by time

detach(dat)

benjaminrich/PCSmisc documentation built on Dec. 17, 2017, 12:50 a.m.