encode: Encode Factor-like Levels and Labels as a Simple String

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

For compact storage, encode combines a set of levels and labels (codes and decodes) into a simple string. The default method converts its argument to character. The list method operates element-wise, expecting and equal number of label elements, each of which have the same length as the corresponding element of x.

Usage

1
2
3
4
5
6
	## Default S3 method:
encode(x, labels = NULL, sep = '/',...)
	## S3 method for class 'character'
encode(x, labels = NULL, sep = '/',...)
	## S3 method for class 'list'
encode(x, labels = NULL, sep = '/',...)

Arguments

x

typically character

labels

typically character

sep

character

...

ignored

Details

An 'encoding' must be at least 5 characters long, beginning and ending with two instances of sep. Specified levels are likewise separated by double separators. If a label (decode) is available for a level, it follows the corresponding level: the two are separated by a single instance of sep. Separators may be mixed within an encoded vector, but not within an element. --0-male--1-female-- indicates that the value 0 represents the concept "male" and the value 1 represents "female".

Value

character

Author(s)

Tim Bergsma

References

http://metrumrg.googlecode.com

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
a <- encode(
  x = list(
    c('M','F'),
    c(1:4)
  ),
  labels = list(
    c('male','female'),
    c('caucasian','asian','african',NA)
  )
)
b <- encode(c(1:2),c('pediatric','adult'))
a
b

anniejw6/metrumrg documentation built on May 10, 2019, 11:50 a.m.