3

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

This function create a plot by passing argument (topN).Here we pass (Top N =20) which plot the top 20 items.Basically the function find top items on the basis of frequency.The function returns plot image which have top items.

Now My Question is that who assigns these top items to a vector or how we get these top items in order to perform additional operation.enter image description here

sebastianmm
  • 1,148
  • 1
  • 8
  • 26
Qaiser iqbal
  • 306
  • 1
  • 14

1 Answers1

3

If you want to get the most frequent items, you can use the function itemFrequency. To get the absolute count of the 20 most frequent items, try

itms <- itemFrequency(myTransactions, type = "absolute")
head(sort(itms, decreasing = TRUE), n = 20)
sebastianmm
  • 1,148
  • 1
  • 8
  • 26
  • Thanks for this But it gives the following whole milk other vegetables rolls/buns soda 2513 1903 1809 1715 How can we get the labels only in vector? e.g(whole milk,soda, etc..) – Qaiser iqbal Jul 25 '17 at 06:47
  • As per its documentation `itemFrequency` returns a named numeric vector. The labels you are looking for are the names of that vector. Therefore: `names(myFreqItems)` – sebastianmm Jul 25 '17 at 06:54