# Pick a small data set and create preference and BTG.
df <- mtcars[1:10,]
pref <- high(mpg) * low(wt)
# Directly plot the BTG with row numbers as labels.
# This uses Rgraphviz if available and igraph otherwise.
plot_btg(df, pref)
# Plot the graph with labels with relevant values.
labels <- paste0(df$mpg, "; ", df$wt)
plot_btg(df, pref, labels)
# Show lattice structure of a 3-dimensional Pareto preference.
df <- merge(merge(data.frame(x = 1:3), data.frame(y = 1:3)), data.frame(z = 1:2))
labels <- paste0(df$x, ",", df$y, ",", df$z)
plot_btg(df, low(x) * low(y) * low(z), labels)
# Create a graph with external Graphviz (requires installed Graphviz).
if (FALSE) {
# Vreates tmpgraph.dot in the current working directoy
get_btg_dot(df, pref, labels, file = "tmpgraph.dot")
# Convert to diagram tmpgraph.png using Graphviz
shell(paste0('"C:/Program Files (x86)/Graphviz2.38/bin/dot.exe"',
' -Tpng tmpgraph.dot -o tmpgraph.png'))
# Open resulting image
shell("tmpgraph.png")}
Run the code above in your browser using DataLab