Debian Codegraph @

man/items.Rd

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