View source: R/carrot_functions_rsq.R
| make_numeric_sets | R Documentation | 
Function which turns a set of predictors containing non-numeric variables into a fully numeric set
make_numeric_sets(a,ai,k,vari,ra,l,mode)
| a | An M x N matrix, containing all possible subsets (N overall) of the size M of predictors' indices; therefore each column of  | 
| ai | array of indices of the array  | 
| k | index of the array  | 
| vari | set of all predictors | 
| ra | array of sample indices of  | 
| l | size of the sample | 
| mode | 
 | 
Function transforms the whole set of predictors into a numeric set by consecutively calling function make_numeric for each predictor
Returns a list containing two objects: tr and test
| tr | training set transformed into a numeric one | 
| test | test set transformed into a numeric one | 
make_numeric
#creating a categorical numeric variable
a<-t(rmultinom(100,1,c(0.2,0.3,0.5)))%*%c(1,2,3)
#creating an analogous non-numeric variable
c<-array(NA,100)
c[a==1]='red'
c[a==2]='green'
c[a==3]='blue'
#creating a data-set
b<-data.frame(matrix(c(a,rbinom(100,1,0.3),runif(100,0,1)),ncol=3))
#making the first column of the data-set non-numeric
b[,1]=data.frame(c)
#running the function
make_numeric_sets(combn(3,2),1:3,1,b,sample(1:100,60),100,"binary")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.