misc {disordR}R Documentation

Miscellaneous functions

Description

This page documents various functions that work for disords, and I will add to these from time to time as I add new functions that make sense for disord objects. Functions like sin() and abs() work as expected: they take and return disord objects with the same hash as x (which means that idiom like x + sin(x) is accepted). However, there are a few functions that are a little more involved:

Arguments

x

Object of class disord

Value

Returns a disord

Note

Some functionality is not yet implemented. Factors, lists, and named vectors do not behave entirely consistently in the package; paste() gives inconsistent results when called with disords.

Also, for() loops are incompatible with disord discipline, as they impose an ordering (for() accesses the .Data slot of its argument, which is a regular R vector). Thus:

> (a <- disord(1:3))
A disord object with hash 555f6bea49e58a2c2541060a21c2d4f9078c3086 and elements
[1] 1 2 3
(in some order)
> for(i in a){print(i)}
[1] 1
[1] 2
[1] 3
> 

Above, we see that for() uses the ordering of the .Data slot of S4 object a, even though elements() has not been explicitly called.

Author(s)

Robin K. S. Hankin

See Also

extract

Examples

a <- disord(c(a=1,b=2,c=7))
a
names(a)
length(a)
sqrt(a)


# powers() and vars() in the mvp package return lists; see the vignette
# for more discussion.

l <- disord(list(3,6:9,1:10))  
sapply(l,length)

unlist(l)

## Quick illustration of rev():

revstring <- function(s){paste(rev(unlist(strsplit(s, NULL))),collapse="")}
x <- rdis()
revstring(hash(x)) == hash(rev(x))


[Package disordR version 0.9-8.2 Index]