Create sliding subvariable definitions
Create a multiple response array variable by sliding through category levels and selecting potentially overlapping sets of categories.
slideCategories(variable, step, width, ..., complete = TRUE, useNA = FALSE)
variable |
A categorical crunch variable |
step |
number of categories between starting points of groups |
width |
number of categories wide the grouping should be |
... |
additional attributes to be included in the |
complete |
whether to only include category groupings that are as wide as width
(defaults to |
useNA |
whether to use missing categories from the original variable (defaults
to |
A list of VariableDefinition
s appropriate for use in deriveArray()
## Not run: login() data <- data.frame( wave = factor(c("a", "b", "c", "d", "e")) ) ds <- newDataset(data, "Sliding Categories") # Make an MR variable where subvariable is 1 step apart, and with 3 categories wide # and name subvariables with vector ds$wave_step1_wide3 <- deriveArray( slideCategories(ds$wave, step = 1, width = 3, name = c("a - c", "b - d", "c - e")), "Sliding example 1" ) # You can also make names (and other subvariable metadata like alias or description) # with a function: ds$wave_step2_wide2 <- deriveArray( slideCategories( ds$wave, step = 2, width = 2, name = function(x) paste(x[1], "-", x[length(x)]) ), "Sliding example 2" ) ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.