Error in eval(predvars, data, env) : object 'PARM' not found

Please help solve this error in R. Note I am very new to R so I would need a step by step explanation please. Everything runs smoothly until the last line. My first column is also very clearly named "PARM". The error occurs as follows:

 #Upload 100% datat data and fix data
> Data <- read.csv("~/Machine_Learning/visualisation.csv", stringsAsFactors=TRUE)
> View(Data)
> Data[is.na(Data)] <- NA
> set.seed(7)
> Data2<-Data
> View(Data2)
> #################################################### ONE #######################3
> #Split data randomly 90-10
> split=0.90
> trainIndex <- createDataPartition(Data2$PRED, p=split, list=FALSE)
> data_train1 <- Data2[ trainIndex,]
> data_test1 <- Data2[-trainIndex,]
> #Generate model
> model1 <- train(PRED ~ ., tuneGrid = data.frame(mtry = 1, min.node.size = 2, splitrule = "gini"), data = data_train1, method = "ranger", num.trees= 500, importance = 'impurity', classification = TRUE, oob.error = TRUE, trControl = trainControl(method="oob", number = 10))
> # make predictions
> x_test1 <- data_test1[,1]
> y_test1 <- data_test1[,2]
> predictions <- predict(model1, x_test1)
Error in eval(predvars, data, env) : object 'PARM' not found

The data starts as foolows:

PARM PRED
-2 3
7 2
-27 1
-25 1
-22 3
10 1
8 2

what does

names(x_test1 )

show ?

"NULL"
so it seems as if it is not registering the imported data column name

In your shoes I would try using dplyr::select to make data.frame x_test1

Thanks. May you please tell me step by step how to do this. I have never worked with R before

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.