group.to.vars: Function to create new variables from the ordinal variable...

Description Usage Arguments Value Examples

Description

This function collapses group memberships or categories of the ordinal variable into binary variables (or indicators) for each category and appends the new variables to the end of the original data. For each new variable, 0 repsrents participants at or below the selected category and 1 reprents participants above the selected category. For example, age.40 = 0 means participants with age at or below 40, whereas age.40 = 1 indicates participants with age beyond 40.

Usage

1

Arguments

data

A data frame or matrix that contains the ordinal variable.

group

The ordinal variable in the 'data' object.

root.name

Indicate whether a root name is used to name the new variables. If not specified (by default, root.name=NULL), the variable name will be used as the root.

Value

A data frame with the original data and newly created variables.

Examples

1
2
3
4
5
6
7
 
#read the example data
data(ROC.data.ex)
#create new binary variables for the ordinal variable
data.new.age<-group.to.vars(ROC.data.ex,
                            ROC.data.ex$age,
                           root.name='age')

ROCpsych documentation built on Aug. 17, 2020, 5:06 p.m.