rdata-sciencearules

Groceries dataset: List transaction with only n items


this is a special question and since I have been for lot of weeks of research I didn't found any answer.

The dataset is Groceries I get with this commands:

install.packages("arules")
library(arules)
data(Groceries)

I try to show the number of transactions that have n items them (in R with R Studio). I am completely stuck. I though at first creating a rule.... but I'm still stuck at this step.

Can someone help me?

Thank you in advance!


Solution

  • This should do it! Let me know if this is what you meant!

    n_items <- 4
    large_transactions <- Groceries[size(Groceries) > n_items]