Simple frequencies with support of labels, weights and multiple response variables.
fre
returns data.frame with six columns: labels or values, counts,
valid percent (excluding NA), percent (with NA), percent of responses(for
single-column x
it equals to valid percent) and cumulative percent of
responses.
fre( x, weight = NULL, drop_unused_labels = TRUE, prepend_var_lab = FALSE, stat_lab = getOption("expss.fre_stat_lab", c("Count", "Valid percent", "Percent", "Responses, %", "Cumulative responses, %")) )
x |
vector/data.frame/list. data.frames are considered as multiple
response variables. If |
weight |
numeric vector. Optional case weights. NA's and negative weights treated as zero weights. |
drop_unused_labels |
logical. Should we drop unused value labels? Default is TRUE. |
prepend_var_lab |
logical. Should we prepend variable label before value
labels? By default we will add variable labels to value labels only if
|
stat_lab |
character. Labels for the frequency columns. |
object of class 'etable'. Basically it's a data.frame but class is needed for custom methods.
data(mtcars) mtcars = modify(mtcars,{ var_lab(vs) = "Engine" val_lab(vs) = c("V-engine" = 0, "Straight engine" = 1) var_lab(am) = "Transmission" val_lab(am) = c(automatic = 0, manual=1) }) fre(mtcars$vs) # stacked frequencies fre(list(mtcars$vs, mtcars$am)) # multiple-choice variable # brands - multiple response question # Which brands do you use during last three months? set.seed(123) brands = data.frame(t(replicate(20,sample(c(1:5,NA),4,replace = FALSE)))) # score - evaluation of tested product score = sample(-1:1,20,replace = TRUE) var_lab(brands) = "Used brands" val_lab(brands) = make_labels(" 1 Brand A 2 Brand B 3 Brand C 4 Brand D 5 Brand E ") var_lab(score) = "Evaluation of tested brand" val_lab(score) = make_labels(" -1 Dislike it 0 So-so 1 Like it ") fre(brands) # stacked frequencies fre(list(score, brands))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.