keyset: Keyset Objects

Description Usage Arguments Details Value See Also Examples

View source: R/keyset.R

Description

Create or test for keyset objects.

Usage

1
2
3
4
5

Arguments

...

keyset variables.

x

object to be converted or tested.

Details

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.

Value

keyset and as.keyset return keyset objects.

is.keyset returns TRUE or FALSE depending on whether its argument is a keyset.

See Also

dataset, as.simple, lookup.

Examples

 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)

patperry/r-frame documentation built on May 6, 2019, 8:34 p.m.