Learn R Programming

arulesViz (version 1.5-0)

associations2igraph: Convert rules or itemsets into a graph

Description

Function to convert associations (rules, itemsets) into a igraph object and saves the graph in different formats (e.g., GraphML, dimacs, dot).

Usage

associations2igraph(x)
saveAsGraph(x, file, format="graphml")

Arguments

x

an object of class "rules" or "itemsets".

file

file name.

format

file format (e.g., "edgelist", "graphml", "dimacs", "gml", "dot"). See write.graph in package igraph.

Value

associations2igraph returns an igraph object.

See Also

plot, write.graph in igraph

Examples

Run this code
# NOT RUN {
data("Groceries")
rules <- apriori(Groceries, parameter=list(support = 0.01, confidence = 0.5))

# convert rules into a graph
g <- associations2igraph(rules)
g

plot(g)

# save rules as a graph so they can be visualized using external tools
saveAsGraph(rules, "rules.graphml")

## clean up
unlink("rules.graphml")
# }

Run the code above in your browser using DataLab