Skip to content

Commit

Permalink
version 1.5-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mhahsler authored and cran-robot committed Nov 19, 2021
1 parent 00e710f commit a547ce3
Show file tree
Hide file tree
Showing 35 changed files with 4,216 additions and 2,870 deletions.
17 changes: 9 additions & 8 deletions DESCRIPTION
@@ -1,28 +1,29 @@
Package: arulesViz
Version: 1.5-0
Date: 2021-5-21
Version: 1.5-1
Date: 2021-11-18
Title: Visualizing Association Rules and Frequent Itemsets
Authors@R: c(person("Michael", "Hahsler", role = c("aut", "cre", "cph"),
email = "mhahsler@lyle.smu.edu"),
person("Giallanza", "Tyler", role = c("ctb")),
person("Sudheer", "Chelluboina", role = c("ctb"))
)
Depends: arules (>= 1.6.0)
Imports: graphics, methods, utils, grDevices, stats, seriation,
colorspace, grid, vcd, igraph, scatterplot3d, ggplot2,
ggnetwork, tibble, tidyr, dplyr, DT, plotly, visNetwork
Suggests: graph, datasets, Rgraphviz, shiny, shinythemes, htmlwidgets
Imports: graphics, methods, utils, grDevices, stats, seriation, grid,
vcd, igraph, scatterplot3d, ggplot2, ggraph, tibble, tidyr,
dplyr, DT, plotly, visNetwork
Suggests: datasets, graph, Rgraphviz, tidygraph, shiny, shinythemes,
htmlwidgets
Description: Extends package 'arules' with various visualization techniques for association rules and itemsets. The package also includes several interactive visualizations for rule exploration. Michael Hahsler (2017) <doi:10.32614/RJ-2017-047>.
License: GPL-3
URL: https://github.com/mhahsler/arulesViz
BugReports: https://github.com/mhahsler/arulesViz/issues
Copyright: (C) 2018 Michael Hahsler, Tyler Giallanza and Sudheer
Chelluboina
NeedsCompilation: no
Packaged: 2021-05-21 19:01:01 UTC; hahsler
Packaged: 2021-11-19 16:24:58 UTC; hahsler
Author: Michael Hahsler [aut, cre, cph],
Giallanza Tyler [ctb],
Sudheer Chelluboina [ctb]
Maintainer: Michael Hahsler <mhahsler@lyle.smu.edu>
Repository: CRAN
Date/Publication: 2021-05-21 19:30:02 UTC
Date/Publication: 2021-11-19 17:40:07 UTC
64 changes: 34 additions & 30 deletions MD5
@@ -1,36 +1,40 @@
7be8b547954409535f87e8539ebf9529 *DESCRIPTION
6d10283fd80c23c12830e1ca71253735 *NAMESPACE
575f667ab6b84737c75e7d2ca826a30a *NEWS.md
2b2794f9674bbf5cfbff4f7f155dd440 *R/AAAhelpers.R
714a5dd1f6ccdb1ea316ea1694a1c73c *R/AAAparameter.R
63f0fd6bb4c650ca78c758b10aa9f6de *R/doubledecker.R
c649297ffcc46c8375e8fb25cb48fd7b *R/gInteraction.R
8c8a931abb60a521d115e48723d7db44 *R/gPlots.R
574201bc6b1846267e1eeed179859e1b *R/ggplot2.R
e2c38319a740c41e6793db7cbc85602d *R/graph.R
630a2b7d941bb5732809eb358f932034 *R/groupedmatrix.R
7e88033f04494601d5283d5f4026dd7c *R/inspectDT.R
fadbcde2b25ce91c0c254516495d19d3 *R/map.R
a8c9f305c28b61de052d38ea65e3aebb *R/matrix.R
39d6aa9c34d0b2384db230596402b47c *R/paracoord.R
5487c0b05def9cd92bcbd1145f6d463c *R/plot.R
50448bffb26c79a73e9ee0ecc59cefb2 *R/plotly.R
aa0d5ea30370998798bda7cca6687acc *R/ruleExplorer.R
cf78937934a16cb88acf1f390e2fa918 *R/saveAsGraph.R
c6b6a4c3a2b8d73b094c7dce6df1c39b *R/scatterplot.R
4789a137837f6d3aef962aa2e1f3b4c3 *R/visNetwork.R
e000cd22323a87500139e608cf249c79 *README.md
d93ea42792725db1acea3a733a5cc90a *build/partial.rdb
63ef5ac2da6d85dade645549a8a31dc8 *build/vignette.rds
45e2d2b13bee228d650a74d00e4d21ab *DESCRIPTION
b0fc9d840a49ee7d5633a9ac8c0889b0 *NAMESPACE
f0f77d39adb403f143e857d576642b08 *NEWS.md
e8488223eb244ac6fc647b85602bb676 *R/check_installed.R
567fad4be85dfe4620fbe77ac128f6ed *R/colors.R
5fd2524a14b182f5cc94acb57aeee872 *R/doubledecker.R
049b5c3e362eb48c3c73578198f52200 *R/gInteraction.R
141b11f5a6a10217e4e773f960b2dcc4 *R/gPlots.R
b78703c9a3a5ca0ca40f46abd1f9be2f *R/ggplot2.R
df411b9589c47c01b390955e05e085c2 *R/ggraph.R
adc3a1f36517d0ecdc1d6ea822c55efa *R/graph.R
e70bb882f099e600aca7f6c60b5ca434 *R/groupedmatrix.R
c178cdc660a0fe4809edfaa409096adb *R/igraph.R
3bdb6d7b0b276ad263f1b21701992b96 *R/inspectDT.R
ad930dcfc0476aa50faf900dafcbcdee *R/limit_associations.R
a5ba023da74e0c7feb654392d79704b2 *R/map.R
5b1660a2a9d6d81735f9997117a6bbfb *R/matrix.R
876ccc19e333078b5621f4445d23edaa *R/paracoord.R
8b1e079c80afa672dfd959872eb71795 *R/parameters.R
349e7e5194ac31ae5ad8efc6b9f81ba4 *R/plot.R
c69ce9d8f91261118903c4777ec485b8 *R/plotly.R
845dc535e300615ef3ad8dc9fb346fbc *R/ruleExplorer.R
a68c66c49a7c9b6f2223fb25c32fc8bc *R/saveAsGraph.R
bb9531a64cd286ac0b0f5f8b3af7e430 *R/scatterplot.R
7531cd5192ad0c2d59499b0d764502d4 *R/visNetwork.R
7d831a219d8eca969a17db6b77f8b675 *README.md
b2bf973cd64f0836b52d9316545c74d0 *build/partial.rdb
3bbae1fe262a46f47d5a67b0b0fa0679 *build/vignette.rds
9cda8d119dfb83199df0efaa17402cbc *inst/CITATION
00d75c7124ddc53272fa5f6f6928e076 *inst/doc/arulesViz.R
7e919833acebff2c81883da78fab96e7 *inst/doc/arulesViz.Rnw
1137911b6e0c115429e24a2af45a5ed6 *inst/doc/arulesViz.pdf
70dc4b6803af3fce70739273a132d76a *man/inspectDT.Rd
6ab01f7def5301abd62632bc2b215f04 *man/plot.Rd
9a436ee57b60ebf587a1b719b7162829 *man/ruleExplorer.Rd
d12ed964dae2f85419dff35d12acd064 *man/rules2matrix.Rd
67783ce4472bdb36474b90494a1d923f *man/saveAsGraph.Rd
ac7a80b3e3cad898ce80a208567afd6b *inst/doc/arulesViz.pdf
2f4fe3735a75f6ab2f1fbfc198ecf39b *man/inspectDT.Rd
bdcc1bbdcd23ed592dd579e0993d8ae8 *man/plot.Rd
e1176ef009bd288751d8b6e8a3265a98 *man/ruleExplorer.Rd
215aa65bd34744e0fd636b8751f5eba2 *man/rules2matrix.Rd
ac0d47e2ea352bddac881b06dbfdcf45 *man/saveAsGraph.Rd
53d9b6775edf3068f77eb3f8b8a63f16 *vignettes/arules.bib
7e919833acebff2c81883da78fab96e7 *vignettes/arulesViz.Rnw
4ba99efc95d7fcaf1d1265cfc0d03a7c *vignettes/arulesViz.bib
Expand Down
6 changes: 6 additions & 0 deletions NAMESPACE
@@ -1,6 +1,7 @@
import("arules")
import("grid")
import("ggplot2")
#import("ggraph")
import("tibble")
import("tidyr")
# NOTE: dplyr has many NAMESPACE conflicts with arules so we use ::
Expand All @@ -10,6 +11,11 @@ importFrom("graphics", "par", "mtext", "text", "axis", "box")
importFrom("stats", "median")
importFrom("methods", "is", "as", "new")

# Otherwise we get: object 'guide_edge_colourbar' of mode 'function' was not found
# Note: has also an alias in man page plot
importFrom("ggraph", "guide_edge_colourbar")
export("guide_edge_colourbar")

importFrom("graphics", "plot")
S3method(plot, rules)
S3method(plot, itemsets)
Expand Down
16 changes: 16 additions & 0 deletions NEWS.md
@@ -1,3 +1,19 @@
# arulesViz 1.5-1 (11/18/2021)

## New features
* plot method "grouped matrix" gained parameter grouped to pass on a grouped matrix.
* associations2igraph gained parameter associationsAsNodes.
* plot method graph with engine vizNetwork can now display itemsets.
* plot gained parameter limit to print only the top limit rules.
* plot method graph with ggraph (ggplot2) gained parameters asEdges = TRUE to represent associations as edges instead of nodes.

## Changes
* we use now a better check for installed suggested packages.
* method graph uses now ggraph.

## Bugfixes
* plot method graph with engine htmlwidget shows not labels correctly.

# arulesViz 1.5-0 (05/21/2021)

## New features
Expand Down
55 changes: 55 additions & 0 deletions R/check_installed.R
@@ -0,0 +1,55 @@
## This is a modified version from package rlang that only uses base R functionality.

## action can be "install" (from CRAN), "stop" (with message), "check" (returns TRUE/FALSE)
## manual can be either TRUE or a string with installation instructions.
check_installed <-
function (pkg,
action = "install",
message = NULL)
{
action <- match.arg(action, choices = c("install", "stop", "check"))

if (!is.character(pkg))
stop("`pkg` must be a package name or a vector of package names.")

needs_install <-
sapply(pkg, function(x)
! requireNamespace(x,
quietly = TRUE))

if (action == "check")
return(!any(needs_install))

if (any(needs_install)) {
if (!interactive())
stop(info)

missing_pkgs <- pkg[needs_install]
missing_pkgs_enum <- paste(missing_pkgs, collapse = ", ")

info <-
paste("The", missing_pkgs_enum,
"package(s) is/are required.")

if (action == "install") {
question <-
"Would you like to install the package(s)?"
cat(info, "\n", question, sep = '')
if (utils::menu(c("Yes", "No")) != 1) {
invokeRestart("abort")
}

utils::install.packages(missing_pkgs)
} else {
### this is stop
cat(info,
"\n",
message,
sep = '')

invokeRestart("abort")
}
}

invisible(TRUE)
}
26 changes: 10 additions & 16 deletions R/AAAhelpers.R → R/colors.R
@@ -1,6 +1,6 @@
#######################################################################
# arulesViz - Visualizing Association Rules and Frequent Itemsets
# Copyrigth (C) 2021 Michael Hahsler
# Copyright (C) 2021 Michael Hahsler
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -17,23 +17,17 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


.installed <- function(pkg) !inherits(try(utils::installed.packages()[pkg,],
silent=TRUE), "try-error")

## color paletts
.col_picker <- function(level, palette, alpha=NULL) {
col <- palette[floor(level*(length(palette)-1))+1]
if(!is.null(alpha)) {
col <- apply(sapply(col, grDevices::col2rgb)/255, 2,
function(x)
grDevices::rgb(x[1], x[2], x[3], alpha=alpha))
## color palettes
.col_picker <- function(level, palette, alpha = NULL) {
col <- palette[floor(level * (length(palette) - 1)) + 1]
if (!is.null(alpha)) {
col <- apply(sapply(col, grDevices::col2rgb) / 255, 2,
function(x)
grDevices::rgb(x[1], x[2], x[3], alpha = alpha))
}
col
}

gray_hcl <- function(n, alpha = 1) colorspace::sequential_hcl(n, c.=0, alpha = alpha)

### default are gray - > red
default_colors <- function(n , alpha = 1)
grDevices::colorRampPalette(c("#EE0000", "#EE9999","#EEEEEE"), alpha = alpha)(n)

default_colors <- function(n , alpha = 1)
grDevices::colorRampPalette(c("#EE0000", "#EE9999", "#EEEEEE"), alpha = alpha)(n)
85 changes: 54 additions & 31 deletions R/doubledecker.R
@@ -1,6 +1,6 @@
#######################################################################
# arulesViz - Visualizing Association Rules and Frequent Itemsets
# Copyrigth (C) 2021 Michael Hahsler
# Copyright (C) 2021 Michael Hahsler
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -23,51 +23,74 @@ rules2table <- function(rules, data) {
transactions <- data[, c(antecedent, consequent)]
ruleAsDataFrame <- as.data.frame(as(transactions, "matrix"))
for (i in 1:ncol(ruleAsDataFrame)) {
ruleAsDataFrame[[i]] <- factor(ruleAsDataFrame[[i]],
levels = c(FALSE, TRUE), labels = c("no", "yes"))
ruleAsDataFrame[[i]] <- factor(
ruleAsDataFrame[[i]],
levels = c(FALSE, TRUE),
labels = c("no", "yes")
)
}
table(ruleAsDataFrame)
}


doubledeckerplot <- function(rules, measure ="support", data,
control=list(), ...) {

doubledeckerplot <- function(rules,
measure = "support",
data,
control = list(),
...) {
engines <- c("default")

if(control$engine == "help") {
message("Available engines for this plotting method are:\n", paste0(engines, collapse = ", "))
return(invisible(engines))
if (control$engine == "help") {
message("Available engines for this plotting method are:\n",
paste0(engines, collapse = ", "))
return(invisible(engines))
}

if(pmatch(control$engine, engines, nomatch = 0) != 1)
stop("Unknown engine for scatterplot: '", control$engine,
if (pmatch(control$engine, engines, nomatch = 0) != 1)
stop("Unknown engine for scatterplot: '",
control$engine,
"' Valid engines: 'default'.")

if(length(rules) != 1) stop("only can visualize one rule.")
if(is.null(data)) stop("data has to be specified, but is missing.")

if (length(rules) != 1)
stop("only can visualize one rule.")
if (is.null(data))
stop("data has to be specified, but is missing.")

control <- c(control, list(...))
control <- .get_parameters(control, list(
main = "Doubledecker plot for 1 rule",
type = "doubledecker",
engine = "default",
interactive = FALSE,
plot_options = list()
))

if(control$interactive) stop("No interactive visualization available for doubledecker/mosaic plot.")

control <- .get_parameters(
control,
list(
main = "Doubledecker plot for 1 rule",
type = "doubledecker",
engine = "default",
interactive = FALSE,
plot_options = list()
)
)

if (control$interactive)
stop("No interactive visualization available for doubledecker/mosaic plot.")

table <- rules2table(rules, data)

if(control$type=="doubledecker")
do.call(vcd::doubledecker, c(list(table, margins=c(2,8,length(dim(table) + 2), 2),
main = control$main), control$plot_options))
if (control$type == "doubledecker")
do.call(vcd::doubledecker, c(
list(
table,
margins = c(2, 8, length(dim(table) + 2), 2),
main = control$main
),
control$plot_options
))
else {
control$main <- "Mosaic plot for 1 rule"
do.call(vcd::mosaic, c(list(table, highlighting = length(dim(table)),
main = control$main), control$plot_options))
do.call(vcd::mosaic, c(
list(
table,
highlighting = length(dim(table)),
main = control$main
),
control$plot_options
))
}
}


0 comments on commit a547ce3

Please sign in to comment.