Learn R Programming

decoder (version 1.1.0)

keyvalue: Coerce to a keyvalue object

Description

Functions to check if an object is a keyvalue object, or coerce it if possible.

Usage

as.keyvalue(x, ...)
"as.keyvalue"(x, standard_var_names = NULL, ...)
"as.keyvalue"(x, y, ...)
is.keyvalue(x)

Arguments

x
object to test for, or coerce to, keyvalue (see the details).
...
arguments passed between methods
standard_var_names
a character vector with standard names for variables decoded with this key-values.
y
a value vector if x is an unnamed vector (argument must be named 'y = .')

Value

as.keyvalue returns a data.frame with additional class keyvalue that fullfills the requirements for a keyvalue object and with the key column as character. It also has two extra attributes standard_var_names as described above and keyvalue11 which is TRUE for keyvalue objects with a 1:1 relation between its keys and values (otherwise FALSE).

Details

x can be of three types:
  • a data.frame with two columns "key" (with unique cells) and "value".
  • a list as described in as.keyvalue.list
  • a named vector with all names unique
  • an unnamed vector with unique cells if supplemented by additional vector (y)

See Also

as.keyvalue.list, key_value_data, decode, summary.keyvalue, key_and_value

Examples

Run this code
snomed <- decoder:::snomed
snomed2 <- as.keyvalue(snomed)
is.keyvalue(snomed2)
summary(snomed2)

Run the code above in your browser using DataLab