weightVariables<- {crunch}R Documentation

Change which variables can be set as a dataset's weight.


modifyWeightVariables allows you to change the variables which are eligible to be used as a dataset's weight. You can also add variables to the weight variables catalog by assignment with weightVariables(ds) <- "weight" or is.weightVariable(ds$weight) <- TRUE.


weightVariables(x) <- value

is.weightVariable(x) <- value

modifyWeightVariables(x, vars, type = "append")

## S4 replacement method for signature 'CrunchDataset'
weightVariables(x) <- value


## S4 replacement method for signature 'NumericVariable'
is.weightVariable(x) <- value



a CrunchDataset


For the weightVariables() and is.weightVariable setters the variables to append to a dataset's weightVariables.


Variables to add or remove this can be a numeric Crunch variable, list of numeric Crunch variables or a character vector with the aliases of numeric Crunch variables. Setting vars to NULL clears a datasets weightVariables


a character string determining how the weightVariables will be modified:

  • "append" : add vars to the current weight variables

  • "remove" : remove vars from the current list of weight variables

  • "replace": replace the current weight variables with vars


Editors can change which variables can be set as the weighting variable for a dataset. For instance if several weights have been calculated they can let the user choose which of those variables to use a weight, but prevent the user from choosing other variables as weight. This function allows you to change the weightVariables of a dataset.


a CrunchDataset


## Not run: 
modifyweightVariables(ds, "weight", "append")
weightVariables(ds) <- list(ds$weight, ds$weight2)
weightVariables(ds) <- NULL
weightVariables(ds) <- c("weight", "weight2")
is.weightVariables(ds$weight) <- TRUE

## End(Not run)

[Package crunch version 1.30.4 Index]