I have been using caret for prediction. It has the var.imp function to extract 'important' variables from the final model. Example below:
library(mlbench)
library(caret)
set.seed(1234)
data(Sonar)
Sonar = Sonar[, 1:6]
inTraining <- createDataPartition(Sonar$V6, p = 0.75, list = FALSE)
training <- Sonar[inTraining, ]
testing <- Sonar[-inTraining, ]
modelFit <- train( V6~.,data=training, method="rf")
varImp(modelFit)
I did the above, and then run the following code to extract these retained variables
ImpMeasure<-data.frame(varImp(modelFit)$importance)
ImpMeasure$Vars<-row.names(ImpMeasure)
However they all have `` around them so I can't merge these variables with their identifiers.
`V1`
`V2`
`V3`
How do I remove the `` ?