0

My algorithm is pretty basic it reads a set of data from a CSV and does some analysis over the data.

It was easy with the box/mosaic/bar plots as they output on the pdf channel by default.

The issues is at inpect(rules) where rules is a set of rules resulted from applying the apriori algorithm

I've tried with textplot(inspect(rules)) => error:

Error in max(sapply(unlist(slist), strwidth, cex = cex)) : 
  invalid 'type' (list) of argument

and also with textplot(rules) => error:

Error in as.character.default(<S4 object of class "rules">) : 
  no method for coercing this S4 class to a vector

Is there a way to output these rules using a plot (this would be better) as it would be more readable.

Or, as final solution to output to pdf as basic text what the print(inspect(rules)) returns.

user1236048
  • 5,542
  • 7
  • 50
  • 87

1 Answers1

0

Came across this while searching for something similar. Presenting the answer here for anyone who comes later.

The main challenge here is, converting the rules to text.

What I observed is, inspect from arules basically "displays" the output. It cannot be assigned to another variable or used in any other way. For programatically converting the rules to text, inspect is not useful.

The right way to convert the rules to text, as I found here is:

as(rules, "data.frame")

Now, you can use your own favourite technique for printing the data frame as text.

Community
  • 1
  • 1
Gopalakrishna Palem
  • 1,705
  • 1
  • 20
  • 34