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 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
\name{items}
\alias{item}
\alias{items}
\alias{item-class}
\alias{item.vector-class}
\alias{integer.item-class}
\alias{double.item-class}
\alias{numeric.item-class}
\alias{character.item-class}
\alias{datetime.item-class}
\alias{Date.item-class}
\alias{as.item}
\alias{as.item,numeric-method}
\alias{as.item,logical-method}
\alias{as.item,character-method}
\alias{as.item,factor-method}
\alias{as.item,ordered-method}
\alias{as.item,POSIXct-method}
\alias{as.item,Date-method}
\alias{as.item,double.item-method}
\alias{as.item,integer.item-method}
\alias{as.item,character.item-method}
\alias{as.item,datetime.item-method}
\alias{as.item,Date.item-method}
\alias{[,item.vector,numeric,missing,missing-method}
\alias{[,item.vector,logical,missing,missing-method}
\alias{[,datetime.item,numeric,missing,missing-method}
\alias{[,datetime.item,logical,missing,missing-method}
\alias{str.double.item}
\alias{str.integer.item}
\alias{str.character.item}
\alias{str.datetime.item}
\alias{unique,item.vector-method}
\alias{summary,item.vector-method}
\alias{summary,datetime.item-method}
\alias{summary,Date.item-method}
\alias{format,item.vector-method}
\alias{show,item.vector-method}
\alias{format,datetime.item-method}
\alias{format,Date.item-method}
\alias{show,datetime.item-method}
\alias{show,Date.item-method}
\alias{print,item.vector-method}
\alias{print,datetime.item-method}
\alias{print,Date.item-method}
\alias{Compare,numeric.item,character-method}
\alias{Compare,character,numeric.item-method}
\alias{Arith,numeric.item,numeric.item-method}
\alias{Arith,numeric.item,numeric-method}
\alias{Arith,numeric,numeric.item-method}
\alias{Math,numeric.item-method}
\alias{Math2,numeric.item-method}
\alias{Summary,numeric.item-method}
\alias{\%in\%,numeric.item,character-method}
\alias{rep,item.vector-method}
\alias{weighted.mean,item.vector-method}
\title{Survey Items}
\description{
Objects of class \code{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 \code{item} is intended to facilitate data management of
survey data. Objects in this class should \emph{not} directly used
in data analysis. Instead they should changed into "ordinary" vectors
or factors before. For this see the documentation for \code{\link{as.vector,item-method}}.
}
\usage{
## The constructor for objects of class "item"
## more convenient than new("item",...)
\S4method{as.item}{numeric}(x,
labels=NULL, missing.values=NULL,
valid.values=NULL, valid.range=NULL,
value.filter=NULL, measurement=NULL,
annotation=attr(x,"annotation"), \dots
)
\S4method{as.item}{character}(x,
labels=NULL, missing.values=NULL,
valid.values=NULL, valid.range=NULL,
value.filter=NULL, measurement=NULL,
annotation=attr(x,"annotation"), \dots
)
\S4method{as.item}{logical}(x,\dots)
# x is first coerced to integer,
# arguments in ... are then passed to the "numeric"
# method.
\S4method{as.item}{factor}(x,\dots)
\S4method{as.item}{ordered}(x,\dots)
\S4method{as.item}{POSIXct}(x,\dots)
\S4method{as.item}{double.item}(x,
labels=NULL, missing.values=NULL,
valid.values=NULL, valid.range=NULL,
value.filter=NULL, measurement=NULL,
annotation=attr(x,"annotation"), \dots
)
\S4method{as.item}{integer.item}(x,
labels=NULL, missing.values=NULL,
valid.values=NULL, valid.range=NULL,
value.filter=NULL, measurement=NULL,
annotation=attr(x,"annotation"), \dots
)
\S4method{as.item}{character.item}(x,
labels=NULL, missing.values=NULL,
valid.values=NULL, valid.range=NULL,
value.filter=NULL, measurement=NULL,
annotation=attr(x,"annotation"), \dots
)
\S4method{as.item}{datetime.item}(x,
labels=NULL, missing.values=NULL,
valid.values=NULL, valid.range=NULL,
value.filter=NULL, measurement=NULL,
annotation=attr(x,"annotation"), \dots
)
}
\arguments{
\item{x}{for \code{as.item} methods,
any atomic vector;
for the \code{unique},
\code{summary}, \code{str}, \code{print}, \code{[}, and \code{<-}
methods, a vector with class \code{labelled}.
}
\item{labels}{a named vector of the same mode as \code{x}.}
\item{missing.values}{either a vector of the same mode as \code{x},
or a list with components \code{"values"},
vector of the same mode as \code{x} (which defines individual missing values)
and \code{"range"} a matrix with two rows with
the same mode as \code{x} (which defines a range of missing values),
or an object of class \code{"missing.values"}.
}
\item{valid.values}{either a vector of the same mode as \code{x},
defining those values of \code{x} that are to be considered as valid,
or an object of class \code{"valid.values"}.}
\item{valid.range}{either a vector of the same mode as \code{x} and length 2,
defining a range of valid values of \code{x},
or an object of class \code{"valid.range"}.}
\item{value.filter}{an object of class \code{"value.filter"}, that is, of
classes \code{"missing.values"}, \code{"valid.values"}, or \code{"valid.range"}.}
\item{measurement}{level of measurement; one of "nominal", "ordinal", "interval", or "ratio".}
\item{annotation}{a named character vector,
or an object of class \code{"annotation"} }
\item{\dots}{further arguments, ignored.}
}
\seealso{
\code{\link{annotation}}
\code{\link{labels}}
\code{\link{value.filter}}
}
\examples{
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 %in% 1:3
test %in% c("a","c")
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 %in% c("A","C")
Test %in% c("a","c")
as.factor(test)
as.factor(Test)
as.numeric(test)
as.character(test)
as.character(Test)
as.data.frame(test)[[1]]
}
\keyword{manip}
|