tuple | R Documentation |
Creation and manipulation of tuples.
tuple(...)
as.tuple(x)
is.tuple(x)
singleton(...)
pair(...)
triple(...)
tuple_is_singleton(x)
tuple_is_pair(x)
tuple_is_triple(x)
tuple_is_ntuple(x, n)
x |
An R object. |
n |
A non-negative integer. |
... |
Possibly named R objects (for |
These functions represent basic infrastructure for handling tuples of
general (R) objects. Class tuple
is used in particular to
correctly handle cartesian products of sets. Although tuple objects
should behave like “ordinary” vectors, some operations might
yield unexpected results since tuple objects are in fact list objects
internally. The Summary
methods do work if
defined for the set elements. The mean
and
median
methods try to convert the object to a numeric vector before calling
the default methods.
set
.
## Constructor.
tuple(1,2,3, TRUE)
triple(1,2,3)
pair(Name = "David", Height = 185)
tuple_is_triple(triple(1,2,3))
tuple_is_ntuple(tuple(1,2,3,4), 4)
## Converter.
as.tuple(1:3)
## Operations.
c(tuple("a","b"), 1)
tuple(1,2,3) * tuple(2,3,4)
rep(tuple(1,2,3), 2)
min(tuple(1,2,3))
sum(tuple(1,2,3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.