Description Usage Arguments Details Value See Also Examples
Create or test for keyset objects.
1 2 3 4 5 |
... |
keyset variables. |
x |
object to be converted or tested. |
A keyset is a dataset of unique, simple values. Such a set is
used for the keys
attribute of a dataset to identify the
rows.
The keyset
function operates like the dataset
function
by creating a keyset with the arguments as columns. The
as.keyset
function coerces its argument to a keyset, and the
is.keyset
tests whether its argument is one.
The code default behavior of as.keyset
is to convert its
argument to a dataset with as.dataset
, and then to convert
the result to simple with as.simple
.
The keyset
and as.keyset
will fail if the result
cannot be converted with as.simple
or if it does not have
unique rows.
keyset
and as.keyset
return keyset objects.
is.keyset
returns TRUE
or FALSE
depending on
whether its argument is a keyset.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | # create a keyset
x <- keyset(k1 = c(1, 1, 2, 2, 3, 3),
k2 = c(letters[1:3], letters[1:3]))
is.keyset(x)
# convert to a keyset
as.keyset(LETTERS)
# invalid: duplicate rows
## Not run: x <- keyset(key = c(1, 2, 3, 1))
# invalid: type cannot be converted to simple
## Not run: val <- 1:3
class(val) <- "foo"
as.keyset(val)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.