items | R Documentation |
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
.
## The constructor for objects of class "item"
## more convenient than new("item",...)
## S4 method for signature '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 signature '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 signature 'logical'
as.item(x,...)
# x is first coerced to integer,
# arguments in ... are then passed to the "numeric"
# method.
## S4 method for signature 'factor'
as.item(x,...)
## S4 method for signature 'ordered'
as.item(x,...)
## S4 method for signature 'POSIXct'
as.item(x,...)
## S4 method for signature '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 signature '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 signature '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 signature '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"), ...
)
x |
for |
labels |
a named vector of the same mode as |
missing.values |
either a vector of the same mode as |
valid.values |
either a vector of the same mode as |
valid.range |
either a vector of the same mode as |
value.filter |
an object of class |
measurement |
level of measurement; one of "nominal", "ordinal", "interval", or "ratio". |
annotation |
a named character vector,
or an object of class |
... |
further arguments, ignored. |
annotation
labels
value.filter
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
test
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
Test
as.factor(test)
as.factor(Test)
as.numeric(test)
as.character(test)
as.character(Test)
as.data.frame(test)[[1]]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.