The dataset that I'm working on is unbalanced, so I'm trying to balance the dataset by using undersampling but I get an error
my code
library(unbalanced)
#convert class to binary
levels(car$class)[1]<-"0"#acc
levels(car$class)[2]<-"1"#good
levels(car$class)[3]<-"2"#unacc
levels(car$class)[4]<-"3"#vgood
#find the number of columns
n_car<-ncol(car)
#class of the data set
outcome_car<-car$class
input_car<-car[ ,-7]
data_car<-ubUnder(X=input_car, Y= outcome_car, perc = 40, method = "percPos")
and here is the error that I got
Error: all(unique(Y) %in% c(0, 1)) is not TRUE
when I try to balance another dataset the code is work well, so I think maybe that's because I have on this dataset 4 levels and on another dataset 2 levels? but how can deal with this error?
thank you