Recodes a dataset with mixed continuous and categorical variables so that the continuous variables come first and the categorical variables have standard coding 1, 2, 3,... (in lexicographical ordering of values coerced to strings).

`discrete.recode(x,xvarsorted=TRUE,continuous=0,discrete)`

x

data matrix or data frame. The data need to be organised case-wise, i.e., if there are categorical variables only, and 15 cases with values c(1,1,2) on the 3 variables, the data matrix needs 15 rows with values 1 1 2. (Categorical variables could take numbers or strings or anything that can be coerced to factor levels as values.)

xvarsorted

logical. If `TRUE`

, the continuous variables
are assumed to be the first ones, and the categorical variables to
be behind them.

continuous

vector of integers giving positions of the
continuous variables. If `xvarsorted=TRUE`

, a single integer,
number of continuous variables.

discrete

vector of integers giving positions of the
categorical variables (the variables need to be coded in such a way that
`data.matrix`

converts them to something numeric). If
`xvarsorted=TRUE`

, a single integer, number of categorical variables.

A list with components

data matrix with continuous variables first and categorical variables in standard coding behind them.

vector of categorical variable-wise numbers of categories.

list of levels of the categorical variables
belonging to what is treated by `flexmixedruns`

as category
1, 2, 3 etc.

number of continuous variables.

number of categorical variables.

# NOT RUN { set.seed(776655) v1 <- rnorm(20) v2 <- rnorm(20) d1 <- sample(c(2,4,6,8),20,replace=TRUE) d2 <- sample(1:4,20,replace=TRUE) ldata <- cbind(v1,d1,v2,d2) lc <- discrete.recode(ldata,xvarsorted=FALSE,continuous=c(1,3),discrete=c(2,4)) require(MASS) data(Cars93) Cars934 <- Cars93[,c(3,5,8,10)] cc <- discrete.recode(Cars934,xvarsorted=FALSE,continuous=c(2,3),discrete=c(1,4)) # }