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,750 points
1,336 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,250 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,030 points
3,440 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,460 points
1,957 views
+1 vote
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,840 points
195,155 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,670 points
6,184 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,570 points
1,036 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,660 points
1,187 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,660 points
5,893 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,660 points
1,119 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,250 points
1,982 views
0 votes
1 answer

How to find out the sum/mean for multiple variables per group in R?

You can use the reshape2 package for ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,250 points
3,829 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP