Antonio López Ruiz
Antonio López Ruiz

Reputation: 1466

discretize function of multiple columns

I have the following csv: https://github.com/antonio1695/Python/blob/master/nearBPO/facturasprueba.csv

With it I want to use the apriori function to find association rules. However, I get the error:

Error in asMethod(object) : column(s) 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 not logical or a factor. Discretize the columns first.

I have already bumped into this error before, and what I did was:

dataframe$columnX <- discretize(df$columnX) 

However, this only works if I select manually each column and discretize them one by one. I would like to do the same thing but for aprox 3k columns. The case I gave you has only 11, I'm guessing that 11 will do.

Upvotes: 3

Views: 7521

Answers (1)

Antonio L&#243;pez Ruiz
Antonio L&#243;pez Ruiz

Reputation: 1466

I found the answer, thanks for everyones help though. To select and discretize multiple columns:

for (i in 2:12){df[,i]<-discretize(df[,i])}

Upvotes: 2

Related Questions