is.sorted | R Documentation |
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).
is.sorted(...)
... |
One or more atomic vectors, all of the same length. |
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).
A logical.
Benjamin Rich <mail@benjaminrich.net>
is.unsorted
order
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.