Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

discretization in R with arules package

I am using arules package to discretize my continuous variables in data frame. I am using this particular line

discretize(data1,categories = 3)

but its giving me an error

Error in cut.default(x,k2) : k2 must be numeric

I am just trying to convert my continuous variables from "data1" data frame to 3 bins discrete variables. Any help would be appreciated...thanks in advance

like image 917
Ankit Bhatia Avatar asked Oct 31 '22 21:10

Ankit Bhatia


1 Answers

Check this code:

library(arules)
data1 <- sample(1:30,100,replace = T)
res <- discretize(data1,categories = 3)

It works correctly. Check

class(data1)

It should be integer or numeric

like image 145
milos.ai Avatar answered Nov 10 '22 10:11

milos.ai