This function receives a data set and check the level of each factor variable, if they have more than 2 levels the function recommend to check the need to transform it to ordered factor.
is a data set with variables to check.
TRUE or FALSE if need or not to tranform the variable into ordered factor.
HAYES, A F; PREACHER, K J. Statistical mediation analysis with a multicategorical independent variable. British Journal of Mathematical and Statistical Psychology, v. 67, n. 3, p. 451-470, 2014.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# Clean environment closeAllConnections() rm(list=ls()) # Set enviroment # setwd("to your working directory") # Load packages library(bnpa) # Use working data sets from package data(dataQualiN) # Show first lines of data set head(dataQualiN) # Insert categorical variables with more than 2 levels dataQualiN$test.variable[dataQualiN$A == "yes"] <- "low" dataQualiN$test.variable[dataQualiN$B == "yes"] <- "medium" dataQualiN$test.variable[dataQualiN$X == "yes"] <- "high" # Transform it to factor variable dataQualiN$test.variable <- as.factor(dataQualiN$test.variable) # Check the necessity to transform in ordered variables bnpa::check.variables.to.be.ordered(dataQualiN)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.