Learn R Programming

disordR (version 0.0-7)

drop: Drop redundant information

Description

Coerce disord objects to vector when this makes sense

Usage

drop(x)
allsame(x)

Arguments

x

disord object

Value

Function drop() returns either a vector or object of class disord as appropriate; allsame() returns a Boolean.

Details

If one has a disord object all of whose elements are identical, one very frequently wants to drop the disord attribute and coerce to a vector. This can be done without ambiguity. Function drop() takes a disord object, and if all elements are identical returns the elements in the form of a vector. Some extraction methods take a drop argument, which does the same thing if TRUE.

Examples

Run this code
# NOT RUN {
drop(disord(c(3,3,3,3,3,3,2,3,3,3,3,3)))
drop(disord(c(3,3,3,3,3,3,3,3,3,3,3,3)))

## In extraction, argument drop discards disorderliness when possible:
a <- rdis()
a[] <- 6             # a becomes a vector
b <- rdis()
b[drop=FALSE] <- 6   # b stays a disord
# }

Run the code above in your browser using DataLab