| SetS3 | R Documentation |
The Set is considered and implemented as a specialized
Container, that is, Set elements are always unique. It provides
typical set operations such as union and intersect.
setnew(..., .ordered = FALSE)
as.set(x)
as.orderedset(x)
is.set(x)
is.orderedset(x)
... |
initial elements put into the |
.ordered |
|
x |
|
Methods that alter Set objects usually come in two versions
providing either copy or reference semantics where the latter start with
'ref_' to note the reference semantic, for example, add() and ref_add().
setnew(...) initializes and returns a Set() object.
as.set(x) coerces x to a set.
as.orderedset(x) coerces x to an ordered set.
is.set(x) returns TRUE if x is of class Set and FALSE
otherwise.
is.orderedset(x) returns TRUE if x is of class OrderedSet
and FALSE otherwise.
x & y performs the set intersection of x and y
x | y performs the set union of x and y
See container() for all inherited methods. For the full class
documentation see Set and it's superclass Container.
s = setnew(1, b = NA, 1:3, c = container("a", 1))
is.set(s)
print(s)
length(s)
names(s)
as.list(s)
unpack(s) # flatten recursively similar to unlist
so = setnew(2, 1, .ordered = TRUE)
print(so)
add(so, 0)
# Math
s = setnew(5:3, 1, 2)
s
abs(s)
cumsum(s)
round(s)
exp(s)
# Summary
range(s)
min(s)
max(s)
s1 = setnew(1, 1:2)
s2 = setnew(2, 1:2)
s1 + s2 # same as s1 | s2 or c(c1, s2)
s2 + s1 # same
s1 - s2
s2 - s1
s1 = setnew(1, b = 2)
s2 = setnew(1, b = 4)
s1 & s2 # {1}
s1 | s2 # {1, b = 2, b = 4}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.