variables.combine: Combine variables

View source: R/variable.update.R

variables.combineR Documentation

Combine variables

Description

Combines one or more variable(s) in a DIGRAM Object.

Usage

variables.combine(
  do = NULL,
  variables.to.combine = NULL,
  variable.name = NULL,
  variable.label = NULL,
  category.names = NULL,
  combine.type = c("sum", "or", "xor", "and", "onlyif"),
  minimum = NULL,
  maximum = NULL,
  cutpoints = NULL
)

Arguments

do

A digram.object

variables.to.combine

The numbers or names of the two or more variables to combine

variable.name

Name of the variable (string)

variable.label

Label of the variable (one or more uppercase letters)

combine.type

How to combine the variables. Values are: "sum": add values of ingoing variables together "or": if one of the variables has a value other than 0, use it (in case of polytomous values, use the highest) "xor": if ONLY one of the variables has a value other than 0, use it "and": if ALL variables has the same value, use it "onlyif" if the first variable has a value, use it. If the second has a value, add it to the first. If the third has a value ... etc.

minimum

Smallest value of the variable (lower values are coded NA)

maximum

Largest value of the variable (lower values are coded NA)

cutpoints

Cutpoints used to recode the variable Category 1: minimum <= values <= cutpoint(1) Category 2: cutpoint(1) < values <= cutpoint(2) ... Category N: cutpoint(n) < values <= maximum

Details

Only ordinal variables can be combined. The resulting variable can be manipulated and deleted as ordinary variables using variable.update and variable.delete.

Value

Returns a DIGRAM object with the new combined variable.

Author(s)

Jeppe Bundsgaard jebu@edu.au.dk

Examples

data(DHP)
DHP<-variables.combine(do=DHP,variables.to.combine=c("dhp36","dhp34"))


jeppebundsgaard/RDigram documentation built on Oct. 29, 2023, 7:15 p.m.