Description Usage Arguments Value Author(s) Examples
Provides the following response options: not at all, very little, somewhat, quite a bit, and a great deal
1 | notAtAllGreatDeal(dat, vars, ord=TRUE)
|
dat |
the data frame |
vars |
a single variable or a list of multiple variables |
ord |
logical indicating whether the items should be ordinal (TRUE:default) or factor (FALSE) |
This function will return response option labels for ordered factors.
Seth Berry, Michael Clark
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function(dat, vars, ord=TRUE){
require(dplyr)
datReduced = select(dat, one_of(vars))
likOrd = lapply(datReduced, function(x)
factor(x,
levels = c(1,2,3,4,5),
labels = c("Not at all", "Very little", "Somewhat",
"Quite a bit", "A great deal"),
ordered=ord)
)
likOrd = as.data.frame(likOrd)
dat[,vars] = likOrd
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.