weightVariables<- {crunch}R Documentation

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

Description

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.

Usage

weightVariables(x) <- value

is.weightVariable(x) <- value

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

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

is.weightVariable(x)

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

Arguments

x

a CrunchDataset

value

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

vars

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

type

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

Details

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.

Value

a CrunchDataset

Examples

## 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]