简体   繁体   English

将先验结果规则输出到R中的PDF

[英]Output apriori resulted rules into PDF in R

My algorithm is pretty basic it reads a set of data from a CSV and does some analysis over the data. 我的算法非常基础,它从CSV读取一组数据并对数据进行一些分析。

It was easy with the box/mosaic/bar plots as they output on the pdf channel by default. 默认情况下,使用箱形图/马赛克图/条形图很容易,因为它们在pdf通道上输出。

The issues is at inpect(rules) where rules is a set of rules resulted from applying the apriori algorithm 问题在于inpect(rules) ,其中rules is a set of rules应用apriori算法产生的rules is a set of rules

I've tried with textplot(inspect(rules)) => error: 我试过了textplot(inspect(rules)) =>错误:

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

and also with textplot(rules) => error: 以及textplot(rules) =>错误:

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. 或者,作为将基本文件输出为pdf的最终解决方案, print(inspect(rules))返回什么。

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. 现在,您可以使用自己喜欢的技术将数据框打印为文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM