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

1 Answer 1

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)
2
  • 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..) Commented Jul 25, 2017 at 6: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) Commented Jul 25, 2017 at 6:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.