# make_numeric: Turning a non-numeric variable into a numeric one In CARRoT: Predicting Categorical and Continuous Outcomes Using One in Ten Rule

## Description

Function which turns a single categorical (non-numeric) variable into a numeric one (or several) by introducing dummy '0'/'1' variables.

## Usage

 `1` ```make_numeric(vari, outcome, ra,mode) ```

## Arguments

 `vari` array of values to be transformed `outcome` TRUE/FALSE indicates whether the variable `vari` is an outcome (TRUE) or a predictor (FALSE) `ra` indices of the input array `vari` which indicate which values will be transformed `mode` `'binary'` (logistic regression), `'multin'` (multinomial regression)

## Details

This function is essentially a standard way to turn categorical non-numeric variables into numeric ones in order to run a regression

## Value

Returned value is an M x N matrix where M is the length of the input array of indices `ra` and N is `length(vari)-1`.

## Examples

 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13``` ```#creating a non-numeric set a<-t(rmultinom(100,1,c(0.2,0.3,0.5)))%*%c(1,2,3) a[a==1]='red' a[a==2]='green' a[a==3]='blue' #running the function make_numeric(a,FALSE,sample(1:100,50),"linear") make_numeric(a,TRUE,sample(1:100,50)) ```

CARRoT documentation built on June 8, 2021, 5:09 p.m.