If one has a disord object all of whose elements are identical, one
usually wants to drop the disord attribute and coerce to a vector.
This can be done without breaking disordR
discipline. Function
disord()
takes a drop
argument, defaulting to
TRUE
, which drops the disord
class from its return value
if all the elements are the same.
Similarly, function drop()
takes a disord object and if all
elements are identical it returns the elements in the form of a
vector. Some extraction methods take a drop
argument, which
does the same thing if TRUE
. This is only useful for disord
objects created with disord(...,drop=FALSE)
The drop
functionality is conceptually similar to the
drop
argument of base R's array extraction, as in
a <- matrix(1:30,5,6)
a[1,,drop=TRUE]
a[1,,drop=FALSE]
Function allsame()
takes a vector and returns TRUE
if
all elements are identical.