measurement memisc 0.99.20.1

Levels of Measurement of Survey Items

Description

The measurement level of a "item" object, which is one of “nominal”, “ordinal”, “interval”, “ratio”, determines what happens to it, if it or the data.set containing it is coerced into a data.frame. If the level of measurement level is “nominal”, the it will be converted into an (unordered) factor, if the level of measurement is “ordinal”, the item will be converted into an ordered vector. If the measurement is “interval” or “ratio”, the item will be converted into a numerical vector.

Usage

## S4 method for signature 'item'
measurement(x)
## S4 method for signature 'item'
measurement(x) <- value
is.nominal(x)
is.ordinal(x)
is.interval(x)
is.ratio(x)

Arguments

x

an object, usually of class "item".

value

a character string; either “nominal”, “ordinal”, “interval”, or “ratio”.

Value

measurement(x) returns a character string. is.nominal, is.ordinal, is.interval, is.ratio return a logical value.

See also

data.set, item

Examples

answer <- sample(c(1,2,3,8,9),size=30,replace=TRUE)
labels(answer) <- c(Conservatives         =  1,
                   Labour                =  2,
                   "Liberal Democrats"   =  3,
                   "Don't know"          =  8,
                   "Answer refused"      =  9
                   )
missing.values(answer) <- c(8,9)
as.data.frame(answer)[[1]]
 [1] Conservatives     <NA>              Conservatives     <NA>
 [5] Conservatives     <NA>              <NA>              Conservatives
 [9] Labour            Conservatives     <NA>              Liberal Democrats
[13] <NA>              Liberal Democrats <NA>              <NA>
[17] <NA>              <NA>              Labour            <NA>
[21] Labour            <NA>              Labour            Liberal Democrats
[25] Labour            <NA>              Labour            <NA>
[29] Labour            Labour
Levels: Conservatives Labour Liberal Democrats
measurement(answer) <- "interval"
as.data.frame(answer)[[1]]
 [1]  1 NA  1 NA  1 NA NA  1  2  1 NA  3 NA  3 NA NA NA NA  2 NA  2 NA  2  3  2
[26] NA  2 NA  2  2