Jelle M
Jelle M

Reputation: 11

Arules in R - values that I exclude keep returning

I am applying the apriori algorithm in R with the database structured as followed (in dput()):

    structure(list(Firm.s.global.reorganization = structure(c(1L, 
2L, 1L, 2L, 2L), .Label = c("no", "yes"), class = "factor"), 
    Delivery.time = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c("no", 
    "yes"), class = "factor"), Automation.of.production.process = structure(c(2L, 
    1L, 2L, 1L, 1L), .Label = c("no", "yes"), class = "factor"), 
    Poor.quality.of.offshored.production = structure(c(1L, 1L, 
    1L, 1L, 1L), .Label = c("no", "yes"), class = "factor"), 
    Made.in.effect = structure(c(1L, 1L, 1L, 1L, 1L), .Label = c("no", 
    "yes"), class = "factor"), Proximity.to.customers = structure(c(1L, 
    1L, 1L, 1L, 1L), .Label = c("no", "yes"), class = "factor")), row.names = c(NA, 
5L), class = "data.frame")

When I run my code I only want values to return that have a "yes" value, thus I use the following code:

rules7 <- apriori(data4, parameter = list(support = 0.05,confidence = 0.5, maxlen=5), appearance=list(rhs=c("Firm.s.global.reorganization=yes"),
                                                                                                      lhs=c("Delivery.time=yes",
                                                                                                        "Automation.of.production.process=yes",
                                                                                                        "Poor.quality.of.offshored.production=yes",
                                                                                                        "Made.in.effect=yes",
                                                                                                        "Proximity.to.customers=yes",
                                                                                                        "Implementation.of.strategies.based.on.product.process.innovation=yes",
                                                                                                        "Untapped.production.capacity=yes",
                                                                                                        "Know.how.in.the.home.country=yes",
                                                                                                        "Change.in.total.costs.of.sourcing=yes",
                                                                                                        "Logistics.costs=yes",
                                                                                                        "Need.for.greater.organizational.flexibility=yes",
                                                                                                        "Economic.crisis=yes",
                                                                                                        "Improve.customer.service=yes",
                                                                                                        "Labour.costs..gap.reduction=yes",
                                                                                                        "Government.support.to.relocation=yes",
                                                                                                        "Proximity.to.suppliers=yes",
                                                                                                        "Loyalty.to.the.home.country=yes"),default="lhs"))

But the results I keep receiving include:

  lhs                                                                        rhs                                   support confidence   coverage     lift count
[1]  {Made.in.effect=no,                                                                                                                                          
      Untapped.production.capacity=no,                                                                                                                            
      Economic.crisis=yes}                                                   => {Firm.s.global.reorganization=yes} 0.02521008  1.0000000 0.02521008 3.838710     6

even though I explicitly used "Made.in.effect=yes" in my code to avoid the "no's".

How can I make sure I only receive "yes" results on both lhs and rhs?

Thanks!

Upvotes: 0

Views: 25

Answers (1)

Jelle M
Jelle M

Reputation: 11

well already fixed it. Incase someone struggles with it in the future: change the default to:

default="none"))

Upvotes: 0

Related Questions