How to classify data for a data collection procedure?

I am performing a data mining procedure using a function apriori. This function works only with categorical data without values, but only with text. My dataset satisfies these requirements, since I have five categorical variables without numerical values, but only text (therefore, the variable "gender" refers to the categories "woman" and "man").

If I try the function now apriori(), I get the following error:

apriori(data)

Error in asMethod(object):

  column(s) 1, 2, 3, 4, 5 not logical or a factor. Use as.factor or categorize first.

Although my data is categorical, R does not understand what it is. How can I use, for example, the as.factor function to categorize my data correctly, so that the apriori function works?

+4
source share
2 answers

You can convert all your columns to a ratio:

data <- sapply(data,as.factor)
+5
source

For me

data <- data.frame(sapply(data,as.factor)) rules<- apriori(data)

Works well

+1
source

All Articles