data: An n x k dataframe or matrix containing only numeric values. Can also be a numeric vector.
m: The column number or name of the moderator variable, if applicable. Leave as NULL if there is no moderator, and set to TRUE if the moderator is the last column in the matrix or dataframe.
nLevels: Number of levels for the ordinal variables.
thresholds: List of length k, where each element is a numeric vector of length (nLevels - 1) containing the splitpoints for grouping each variable into ordered categories.
mthresh: Vector of length (nLevels - 1) containing thresholds to group values of the moderator into ordered categories.
mord: if FALSE, then the moderator will not be converted into an ordinal variable (if applicable).
minOrd: The minimum number of unique values allowed for each variable.
Returns
A dataframe or matrix containing the ordinalized data.
Details
If a moderator value is specified via the m argument, that variable will automatically be relegated to the last column of the resultant dataframe or matrix. It will also be renamed "M"
Examples
dat <- data.frame(sapply(1:5,function(z) rnorm(100)))ord_dat <- ordinalize(dat)# Including a moderator, without converting the moderator into an ordinal variableord_dat <- ordinalize(dat, m =5, mord =FALSE)colnames(dat)[5]<-'M'ord_dat <- ordinalize(dat, m ='M', mord =FALSE)# Use thresholds to break each variable into quartilesthresh <- lapply(dat,function(z) quantile(z, probs = c(.25,.5,.75)))ord_dat <- ordinalize(dat, thresholds = thresh)