reversed {memisc} | R Documentation |
Reverse the codes of a survey item or the levels of a factor
Description
The function reversed()
returns a copy of its argument with codes
or levels in reverse order.
Usage
reversed(x)
## S4 method for signature 'item.vector'
reversed(x)
## S4 method for signature 'factor'
reversed(x)
Arguments
x |
An object – an "item" object or a "data.set" object |
Value
If the argument of the function reversed()
than either the
unique valid values or the labelled valid values recoded into the
reverse order.
If th argument is a factor than the function returns the factor with levels in reverse order.
Examples
ds <- data.set(
x = as.item(sample(c(1:3,9),100,replace=TRUE),
labels=c("One"=1,
"Two"=2,
"Three"=3,
"Missing"=9)))
df <- as.data.frame(ds)
ds <- within(ds,{
xr <- reversed(x)
})
codebook(ds)
df <- within(df,{
xr <- reversed(x)
})
codebook(df)
[Package memisc version 0.99.31.7 Index]