Extract lhs items from rules in R

0 votes

How to extract lhs items from rules generated from arules?

For example, consider,

{a,b,c} => {d}

I want to extract a,b,c and put it in a character vector. I want to do this so that I can iterate and do further processing based on these items.

I have thought of a way where I can parse a set of rules, convert it to a data frame and then separate items using character manipulations.

Is there any better way to do this?

Jun 20, 2018 in Data Analytics by CodingByHeart77
• 3,680 points
57 views

1 answer to this question.

0 votes

Try the following code:

data("Adult")
rules <- apriori(Adult, 
   parameter = list(supp = 0.5, conf = 0.9, target = "rules"))

as(lhs(rules), "list")
as(rhs(rules), "list")
answered Jun 20, 2018 by DataKing99
• 8,130 points

Related Questions In Data Analytics

0 votes
1 answer

Extract text from image in R

Try below code to fetch the image ...READ MORE

answered Aug 6 in Data Analytics by anonymous
• 25,820 points
27 views
0 votes
4 answers

How to remove NA values from a Vector in R?

You can try na.omit() or na.exclude() too. ...READ MORE

answered Jul 31 in Data Analytics by anonymous
• 25,820 points
6,085 views
0 votes
1 answer

How can I delete multiple values from a vector in R?

The %in% operator tells  which elements are ...READ MORE

answered Apr 26, 2018 in Data Analytics by shams
• 3,580 points
121 views
0 votes
1 answer

How to find common elements from multiple vectors in R?

Reduce(intersect, list(a,b,c)) READ MORE

answered Apr 26, 2018 in Data Analytics by DeepCoder786
• 1,700 points
625 views
0 votes
1 answer

Big Data transformations with R

Dear Koushik, Hope you are doing great. You can ...READ MORE

answered Dec 17, 2017 in Data Analytics by Sudhir
• 1,610 points
47 views
0 votes
2 answers

Transforming a key/value string into distinct rows in R

We would start off by loading the ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
61 views
0 votes
1 answer

Finding frequency of observations in R

You can use the "dplyr" package to ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
125 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

The below is the code to perform ...READ MORE

answered Mar 26, 2018 in Data Analytics by Bharani
• 4,550 points
102 views
0 votes
1 answer

Drop unused levels from a data frame in R

You can use this command droplevels() y <- ...READ MORE

answered Jun 14, 2018 in Data Analytics by DataKing99
• 8,130 points
233 views
0 votes
1 answer

What are the options for deploying models in production with R?

Well, I could say that the answer ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,130 points
250 views