codes: Recover Metadata from spec Objects and their Components

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

Description

A spec object has metadata stored compactly in its ‘label’ and ‘guide’ columns. Methods here extract metadata, acting on the relevant column directly or on the object as a whole.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
	## Default S3 method:
encoded(x, ...)
	## Default S3 method:
  codes(x, simplify=TRUE, ...)
	## Default S3 method:
decodes(x, simplify=TRUE, ...)
	## S3 method for class 'spec'
   encoded(x, column=x$column, ...)
	## S3 method for class 'spec'
     codes(x, column=x$column, ...)
	## S3 method for class 'spec'
   decodes(x, column=x$column, ...)
	## S3 method for class 'spec'
    labels(object, column=object$column, ...)
	## S3 method for class 'spec'
 guidetext(x, column=x$column, ...)

Arguments

x

character, or spec

object

character, or spec

simplify

reduce a list to a vector if possible

column

which column(s) to address

...

ignored

Details

encoded always returns TRUE or FALSE, telling whether the corresponding element represents an encoding of levels and labels. See encode. codes returns a list(or vector) giving the element-wise codes (levels) or NA; decodes returns the corresponding decodes (labels) or NA. labels returns the descriptors for column names; don't confuse with the labels for factor-like levels (decodes). guidetext returns the portion of a numeric guide element that is not a range specifier (if any): e.g. just 'kg' for 'kg [0,30)'.

Value

list or vector

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
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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
c <- c('a',NA,'##b##')
encoded(a)
encoded(b)
encoded(c)
encoded(' //4// ')
codes(a)
codes(b)
codes(b,simplify=FALSE)
codes(c)
codes('..1..')
decodes(a)
decodes(b)
decodes(c)
example(matches)

metrumrg documentation built on May 2, 2019, 5:55 p.m.