I'm trying to plot the variable importance scores for the below model.
The scores output fine but they're not plotting properly- do I need to add another parameter to the code?
Code and Output of Scores are below.
library(caret)
#GENERALISED LINEAR MODEL
LR_swim <- lm(racetime_mins ~ event_date+ event_month +year +event_id +
gender + distance_new + New_Condition+
raceNo_Updated +
handicap_mins +points+
Wind_Speed_knots+
Air_Temp_Celsius +Water_Temp_Celsius +Wave_Height_m,
data = SwimmingTrain)
family=gaussian(link = "identity")
varImp2<-varImp(object=LR_swim)
plot(varImp2,main="Variable Importance")
Overall event_date 24.463358 event_month 22.358448 year 24.399390 event_id 26.878342 genderfemale 30.422470 gendermale 13.273062 distance_new 248.727351 New_Condition 22.574999 raceNo_Updated 9.812053 handicap_mins 134.914137 points 40.443116 Wind_Speed_knots 14.492203 Air_Temp_Celsius 16.562194 Water_Temp_Celsius 2.861662 Wave_Height_m 8.592716
#ClassOutput
class(varImp2)
[1] "data.frame"
#HeadOutput
> head(varImp2)
Overall
event_date 24.46336
event_month 22.35845
year 24.39939
event_id 26.87834
genderfemale 30.42247
gendermale 13.27306
Mine looks like;
Supposed to look like



class(vaImp2)andhead(varImp2)in your question? So we can see the format and type of thevaImp2. - maydinplot(varImp2[,1],main="Variable Importance")? - maydin