How to do it...

Perform the following steps to display transactions and associations:

  1. First, you can obtain a LIST representation of the transaction data:
        > LIST(trans)
        Output
        $Tr1
        [1] "Apple" "Bread" "Cake" 
    
        $Tr2
        [1] "Apple" "Bread" "Milk" 
    
        $Tr3
        [1] "Bread" "Cake"  "Milk"
  1. Next, you can use the summary function to show a summary of the statistics and details of the transactions:
        > summary(trans)
Output
transactions as itemMatrix in sparse format with
3 rows (elements/itemsets/transactions) and
4 columns (items) and a density of 0.75

most frequent items:
Bread Apple Cake Milk (Other)
3 2 2 2 0

element (itemset/transaction) length distribution:
sizes
3
3

Min. 1st Qu. Median Mean 3rd Qu. Max.
3 3 3 3 3 3

includes extended item information - examples:
labels
1 Apple
2 Bread
3 Cake

includes extended transaction information - examples:
transactionID
1 Tr1
2 Tr2
3 Tr3
  1. You can then display transactions using the inspect function:
        > inspect(trans)
        Output
          items   transactionID
         1 {Apple,              
           Bread,              
        Cake}            Tr1
        2 {Apple,              
           Bread,              
        Milk}            Tr2
        3 {Bread,              
            Cake,               
        Milk}            Tr3  
  1. In addition to this, you can filter the transactions by size:
        > filter_trains = trans[size(trans) >=3]
        > inspect(filter_trains)
        Output
          items   transactionID
        1 {Apple,              
           Bread,              
        Cake}            Tr1
        2 {Apple,              
           Bread,              
        Milk}            Tr2
        3 {Bread,              
           Cake,               
        Milk}            Tr3  
  1. Also, you can use the image function to visually inspect the transactions:
        > image(trans)
Visual inspection of transactions
  1. To visually show the frequency/support bar plot, one can use itemFrequenctPlot:
        > itemFrequencyPlot (trans)
Item frequency bar plot of transactions
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset