[R] Consequent sorting

Jeff Reichman reichm@nj @ending from @bcglob@l@net
Mon Sep 24 00:18:07 CEST 2018


r-help Forum

 

I'm using the following code to sort the "right-hand side (rhs, consequent)
of the rules output from the arules packages, which works.  But what I'd
really like is the ability to subset my rules where the rhs = "some item
set"

 

rules_info <-

  data.frame(

    LHS = labels(lhs(rules)), 

    RHS = labels(rhs(rules)),          

    quality(rules)

  )

 

rules_info[ order(rules_info$RHS=), ]

 

For example using my code above I'm able to sort as follow's

 

179  {Cereals,Eggs,Tomatoes,Vinegar}    {Bread} 0.1428571  1.0000000
1.1666667     1

184           {Eggs,Milk,Pork,Sugar}    {Bread} 0.1428571  1.0000000
1.1666667     1

189        {Eggs,Milk,Pork,Tomatoes}    {Bread} 0.1428571  1.0000000
1.1666667     1

1                                 {}  {Cereals} 0.2857143  0.2857143
1.0000000     2

8                          {Vinegar}  {Cereals} 0.1428571  1.0000000
3.5000000     1

15                        {Tomatoes}  {Cereals} 0.1428571  0.5000000
1.7500000     1

17                            {Eggs}  {Cereals} 0.2857143  0.3333333
1.1666667     2

 

But what I'd really like to do is just get (say) {Bread} like .

 

                                 LHS        RHS   support confidence
lift count

179  {Cereals,Eggs,Tomatoes,Vinegar}    {Bread} 0.1428571  1.0000000
1.1666667     1

184           {Eggs,Milk,Pork,Sugar}    {Bread} 0.1428571  1.0000000
1.1666667     1

189        {Eggs,Milk,Pork,Tomatoes}    {Bread} 0.1428571  1.0000000
1.1666667     1

 

Jeff Reichman

 


	[[alternative HTML version deleted]]



More information about the R-help mailing list