| 1 |
\name{measurement} |
| 2 |
\alias{measurement} |
| 3 |
\alias{measurement,ANY-method} |
| 4 |
\alias{measurement,item-method} |
| 5 |
\alias{measurement,data.set-method} |
| 6 |
\alias{measurement<-} |
| 7 |
\alias{measurement<-,item-method} |
| 8 |
\alias{measurement<-,data.set-method} |
| 9 |
\alias{set_measurement} |
| 10 |
\alias{is.nominal} |
| 11 |
\alias{is.ordinal} |
| 12 |
\alias{is.interval} |
| 13 |
\alias{is.ratio} |
| 14 |
\alias{as.nominal} |
| 15 |
\alias{as.ordinal} |
| 16 |
\alias{as.interval} |
| 17 |
\alias{as.ratio} |
| 18 |
\title{Levels of Measurement of Survey Items} |
| 19 |
\description{ |
| 20 |
The measurement level of a \code{"item"} object, which is one of "nominal", "ordinal", "interval", "ratio", |
| 21 |
determines what happens to it, if it or the \code{\link{data.set}} |
| 22 |
containing it is coerced into a \code{\link{data.frame}}. |
| 23 |
If the level of measurement level is "nominal", the it will be |
| 24 |
converted into an (unordered) \link{factor}, if the level of measurement is "ordinal", |
| 25 |
the item will be converted into an \link{ordered} vector. If the measurement |
| 26 |
is "interval" or "ratio", the item will be converted into a numerical vector. |
| 27 |
} |
| 28 |
\usage{ |
| 29 |
\S4method{measurement}{item}(x) |
| 30 |
\S4method{measurement}{item}(x) <- value |
| 31 |
\S4method{measurement}{data.set}(x) |
| 32 |
\S4method{measurement}{data.set}(x) <- value |
| 33 |
is.nominal(x) |
| 34 |
is.ordinal(x) |
| 35 |
is.interval(x) |
| 36 |
is.ratio(x) |
| 37 |
as.nominal(x) |
| 38 |
as.ordinal(x) |
| 39 |
as.interval(x) |
| 40 |
as.ratio(x) |
| 41 |
set_measurement(x,\dots) |
| 42 |
} |
| 43 |
\arguments{ |
| 44 |
\item{x}{an object, usually of class \code{"item"}.} |
| 45 |
\item{value}{ |
| 46 |
for the \code{item} method, |
| 47 |
a character string; either "nominal", "ordinal", "interval", or |
| 48 |
"ratio"; |
| 49 |
for the \code{data.set} method, |
| 50 |
a list of character vectors with variable names, |
| 51 |
where the names of the list corresponds to a measurement level and |
| 52 |
and the list elements indicates the variables to which the |
| 53 |
measurement levels are assigned. |
| 54 |
} |
| 55 |
\item{\dots}{vectors of variable names, either symbols or character |
| 56 |
strings, tagged with the intended measurement level. |
| 57 |
} |
| 58 |
} |
| 59 |
\value{ |
| 60 |
The \code{item} method of \code{measurement(x)} returns a character |
| 61 |
string, the \code{data.set} method returns a named character vector, |
| 62 |
where the name of each element is a variable name and each. |
| 63 |
|
| 64 |
\code{as.nominal}, \code{as.ordinal}, \code{as.interval}, \code{as.ratio} |
| 65 |
return an item with the requested level of measurement setting. |
| 66 |
|
| 67 |
\code{is.nominal}, \code{is.ordinal}, \code{is.interval}, \code{is.ratio} |
| 68 |
return a logical value. |
| 69 |
} |
| 70 |
\references{ |
| 71 |
Stevens, Stanley S. 1946. "On the theory of scales of measurement." \emph{Science} 103: 677-680. |
| 72 |
} |
| 73 |
\seealso{\code{\link{data.set}}, \code{\link{item}}} |
| 74 |
\examples{ |
| 75 |
vote <- sample(c(1,2,3,8,9),size=30,replace=TRUE) |
| 76 |
labels(vote) <- c(Conservatives = 1, |
| 77 |
Labour = 2, |
| 78 |
"Liberal Democrats" = 3, |
| 79 |
"Don't know" = 8, |
| 80 |
"Answer refused" = 9 |
| 81 |
) |
| 82 |
missing.values(vote) <- c(8,9) |
| 83 |
as.data.frame(vote)[[1]] |
| 84 |
measurement(vote) <- "interval" |
| 85 |
as.data.frame(vote)[[1]] |
| 86 |
vote <- as.nominal(vote) |
| 87 |
as.data.frame(vote)[[1]] |
| 88 |
group <- sample(c(1,2),size=30,replace=TRUE) |
| 89 |
labels(group) <- c(A=1,B=2) |
| 90 |
DataS <- data.set(group,vote) |
| 91 |
measurement(DataS) |
| 92 |
measurement(DataS) <- list(interval=c("group","vote")) |
| 93 |
head(as.data.frame(DataS)) |
| 94 |
DataS <- set_measurement(DataS, |
| 95 |
nominal=c(group,vote)) |
| 96 |
head(as.data.frame(DataS)) |
| 97 |
} |
| 98 |
\keyword{manip} |