Description Usage Arguments Details Value Examples
View source: R/carrot_functions.R
Function which turns a single categorical (nonnumeric) variable into a numeric one (or several) by introducing dummy '0'/'1' variables.
1  make_numeric(vari, outcome, ra,mode)

vari 
array of values to be transformed 
outcome 
TRUE/FALSE indicates whether the variable 
ra 
indices of the input array 
mode 

This function is essentially a standard way to turn categorical nonnumeric variables into numeric ones in order to run a regression
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
.
1 2 3 4 5 6 7 8 9 10 11 12 13  #creating a nonnumeric 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))

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.