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,720 points
528 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,240 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 7, 2019 in Data Analytics by anonymous
• 33,010 points
1,677 views
0 votes
1 answer

How to extract specific columns from a dataframe in R?

Hi@akhtar, You can use the select method to ...READ MORE

answered Aug 7, 2020 in Data Analytics by MD
• 95,320 points
573 views
0 votes
5 answers

How to remove NA values from a Vector in R?

Hello team, you can use na.omit x <- c(NA, 3, ...READ MORE

answered Dec 9, 2020 in Data Analytics by anonymous
• 82,880 points
127,594 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 27, 2018 in Data Analytics by shams
• 3,660 points
5,172 views
0 votes
1 answer

Big Data transformations with R

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

answered Dec 18, 2017 in Data Analytics by Sudhir
• 1,610 points
356 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,620 points
399 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,620 points
3,848 views
0 votes
1 answer

Left Join and Right Join using "dplyr"

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

answered Mar 27, 2018 in Data Analytics by Bharani
• 4,620 points
437 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,240 points
1,190 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,240 points
893 views