labels: Value Labels

Description Usage Arguments Examples

Description

Value labels associate character labels to possible values of an encoded survey item. Value labels are represented as objects of class "value.labels".

Value labels of an item can be obtained using labels(x) and can be associated to items and to vectors using labels(x) <- value

Value labels also can be updated using the + and - operators.

Usage

1
2
labels(object,...)
labels(x) <- value

Arguments

object

any object.

...

further arguments for other methods.

x

a vector or "item" object.

value

an object of class "value.labels" or a vector that can be coerced into an "value.labels" object or NULL

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
  x <- as.item(rep(1:5,4),
      labels=c(
          "First"      = 1,
          "Second"     = 2,
          "Third"      = 3,
          "Fourth"     = 4,
          "Don't know" = 5
        ),
      missing.values=5,
      annotation = c(
        description="test"
      ))
  labels(x)
  labels(x) <- labels(x) - c("Second"=2)
  labels(x)
  labels(x) <- labels(x) + c("Second"=2)
  labels(x)

  puvl <- getOption("print.use.value.labels")
  options(print.use.value.labels=FALSE)
  x
  options(print.use.value.labels=TRUE)
  x
  options(print.use.value.labels=puvl)

Example output

Loading required package: lattice
Loading required package: MASS

Attaching package: 'memisc'

The following objects are masked from 'package:stats':

    contr.sum, contr.treatment, contrasts

The following object is masked from 'package:base':

    as.array


 Values and labels:

   1 'First'     
   2 'Second'    
   3 'Third'     
   4 'Fourth'    
   5 'Don't know'


 Values and labels:

   1 'First'     
   3 'Third'     
   4 'Fourth'    
   5 'Don't know'


 Values and labels:

   1 'First'     
   2 'Second'    
   3 'Third'     
   4 'Fourth'    
   5 'Don't know'


Item 'test' (measurement: nominal, type: integer, length = 20) 

 [1:20] 1 2 3 4 *5 1 2 3 4 *5 1 2 3 4 *5 1 2 3 4 *5

Item 'test' (measurement: nominal, type: integer, length = 20) 

 [1:20] First Second Third Fourth *Don't know First Second Third Fourth ...

memisc documentation built on May 2, 2019, 5:45 p.m.

Related to labels in memisc...