R apriori algorithm - How to assign the top items of ItemFrequency () to a vector?

I am working in the R apriori algorithm which has the ItemFrequencyPlot () function of the arules library.

This function creates a graph by passing an argument (topN). Here we are passing in (Top N = 20) that occupy the top 20 elements. Basically the function finds the top items based on frequency. The function returns the graph image that has the top elements.

Now my question is who is assigning these tops to the vector or how do we get these tops to perform an additional operation. enter image description here

+3


source to share


1 answer


If you want to get the most used items, you can use the function itemFrequency

. To get an absolute count of the 20 most used items try



itms <- itemFrequency(myTransactions, type = "absolute")
head(sort(itms, decreasing = TRUE), n = 20)

      

+3


source







All Articles