0

I am getting the error below when I execute my code in R.

Error in optbin(train): could not find function "optbin" Traceback:

Below is my code:

#Read datasets
#Download the data from http://www.saedsayad.com/datasets/CreditData.zip
train <- read.csv("Credit_train.csv")
test <- read.csv("Credit_test.csv")

#Rows and Cols
dim(train)
dim(test)

#Columns name
colnames(train)
colnames(test)

#Show  
head(train)
head(test)


#------
# OneR
#------


#remove all records with missing values
train <- na.omit(train)
test <- na.omit(test)

#binning the numerical variable
train.bin <- optbin(train)

#train
model.OneR <- OneR(DEFAULT~., data = train.bin, verbose = TRUE)
summary(model.OneR)
plot(model.OneR)

#test
pc <-NULL
pc <- predict(model.OneR, test, type = "class")
eval_model(pc,test)

I have applied oneR package and it's still not working. What must I do to get this error resolved ?

UnknownBatman
  • 65
  • 1
  • 4
  • 1
    did you load the relevant `library`? see https://stackoverflow.com/questions/7027288/error-could-not-find-function-in-r for more suggestions – user20650 Feb 24 '21 at 00:12

1 Answers1

1

Try loading the library using either library or require before using the function

library(OneR)

Alternatively you can use the namespace specifier

OneR::optbin
Oliver
  • 8,169
  • 3
  • 15
  • 37