items

0th

Percentile

Survey Items

Objects of class item are data vectors with additional information attached to them like ``value labels'' and ``user-defined missing values'' known from software packages like SPSS or Stata.

The class item is intended to facilitate data management of survey data. Objects in this class should not directly used in data analysis. Instead they should changed into "ordinary" vectors or factors before. For this see the documentation for as.vector,item-method.

Keywords
manip
Usage
## The constructor for objects of class "item"
## more convenient than new("item",...)
# S4 method for numeric
as.item(x,
  labels=NULL,  missing.values=NULL,
  valid.values=NULL,  valid.range=NULL,
  value.filter=NULL,  measurement=NULL,
  annotation=attr(x,"annotation"), …
  )
# S4 method for character
as.item(x,
  labels=NULL,  missing.values=NULL,
  valid.values=NULL,  valid.range=NULL,
  value.filter=NULL,  measurement=NULL,
  annotation=attr(x,"annotation"), …
  )

# S4 method for logical as.item(x,…) # x is first coerced to integer, # arguments in ... are then passed to the "numeric" # method.

# S4 method for factor as.item(x,…) # S4 method for ordered as.item(x,…) # S4 method for POSIXct as.item(x,…)

# S4 method for double.item as.item(x, labels=NULL, missing.values=NULL, valid.values=NULL, valid.range=NULL, value.filter=NULL, measurement=NULL, annotation=attr(x,"annotation"), … )

# S4 method for integer.item as.item(x, labels=NULL, missing.values=NULL, valid.values=NULL, valid.range=NULL, value.filter=NULL, measurement=NULL, annotation=attr(x,"annotation"), … )

# S4 method for character.item as.item(x, labels=NULL, missing.values=NULL, valid.values=NULL, valid.range=NULL, value.filter=NULL, measurement=NULL, annotation=attr(x,"annotation"), … )

# S4 method for datetime.item as.item(x, labels=NULL, missing.values=NULL, valid.values=NULL, valid.range=NULL, value.filter=NULL, measurement=NULL, annotation=attr(x,"annotation"), … )

Arguments
x

for as.item methods, any atomic vector; for the unique, summary, str, print, [, and <- methods, a vector with class labelled.

labels

a named vector of the same mode as x.

missing.values

either a vector of the same mode as x, or a list with components "values", vector of the same mode as x (which defines individual missing values) and "range" a matrix with two rows with the same mode as x (which defines a range of missing values), or an object of class "missing.values".

valid.values

either a vector of the same mode as x, defining those values of x that are to be considered as valid, or an object of class "valid.values".

valid.range

either a vector of the same mode as x and length 2, defining a range of valid values of x, or an object of class "valid.range".

value.filter

an object of class "value.filter", that is, of classes "missing.values", "valid.values", or "valid.range".

measurement

level of measurement; one of "nominal", "ordinal", "interval", or "ratio".

annotation

a named character vector, or an object of class "annotation"

further arguments, ignored.

See Also

annotation labels value.filter

Aliases
  • item
  • items
  • item-class
  • item.vector-class
  • integer.item-class
  • double.item-class
  • numeric.item-class
  • character.item-class
  • datetime.item-class
  • Date.item-class
  • as.item
  • as.item,numeric-method
  • as.item,logical-method
  • as.item,character-method
  • as.item,factor-method
  • as.item,ordered-method
  • as.item,POSIXct-method
  • as.item,Date-method
  • as.item,double.item-method
  • as.item,integer.item-method
  • as.item,character.item-method
  • as.item,datetime.item-method
  • as.item,Date.item-method
  • [,item.vector,numeric,missing,missing-method
  • [,item.vector,logical,missing,missing-method
  • [,datetime.item,numeric,missing,missing-method
  • [,datetime.item,logical,missing,missing-method
  • str.double.item
  • str.integer.item
  • str.character.item
  • str.datetime.item
  • unique,item.vector-method
  • summary,item.vector-method
  • summary,datetime.item-method
  • summary,Date.item-method
  • format,item.vector-method
  • show,item.vector-method
  • format,datetime.item-method
  • format,Date.item-method
  • show,datetime.item-method
  • show,Date.item-method
  • print,item.vector-method
  • print,datetime.item-method
  • print,Date.item-method
  • Compare,numeric.item,character-method
  • Compare,character,numeric.item-method
  • Arith,numeric.item,numeric.item-method
  • Arith,numeric.item,numeric-method
  • Arith,numeric,numeric.item-method
  • Math,numeric.item-method
  • Math2,numeric.item-method
  • Summary,numeric.item-method
  • %in%,numeric.item,character-method
  • rep,item.vector-method
  • weighted.mean,item.vector-method
Examples
# NOT RUN {
  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"
      ))
  str(x)
  summary(x)
  as.numeric(x)

  test <- as.item(rep(1:6,2),labels=structure(1:6,
                                      names=letters[1:6]))
  test
  test == 1
  test != 1
  test == "a"
  test != "a"
  test == c("a","z")
  test != c("a","z")
  test 
# }
# NOT RUN {
<!-- %in% 1:3 -->
# }
# NOT RUN {
  test 
# }
# NOT RUN {
<!-- %in% c("a","c") -->
# }
# NOT RUN {
  codebook(test)

  Test <- as.item(rep(letters[1:6],2),
                    labels=structure(letters[1:6],
                                     names=LETTERS[1:6]))
  Test
  Test == "a"
  Test != "a"
  Test == "A"
  Test != "A"
  Test == c("a","z")
  Test != c("a","z")
  Test 
# }
# NOT RUN {
<!-- %in% c("A","C") -->
# }
# NOT RUN {
  Test 
# }
# NOT RUN {
<!-- %in% c("a","c") -->
# }
# NOT RUN {
  as.factor(test)
  as.factor(Test)
  as.numeric(test)
  as.character(test)
  as.character(Test)

  as.data.frame(test)[[1]]
# }
Documentation reproduced from package memisc, version 0.99.27.3, License: GPL-2

Community examples

Looks like there are no examples yet.