Skip to content

Commit

Permalink
We use not roxygen.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhahsler committed Sep 7, 2023
1 parent 01da672 commit f8735af
Show file tree
Hide file tree
Showing 18 changed files with 1,028 additions and 293 deletions.
7 changes: 5 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: arulesViz
Version: 1.5-2
Date: 2023-03-07
Version: 1.5.2-1
Date: 2023-xx-xx
Title: Visualizing Association Rules and Frequent Itemsets
Authors@R: c(person("Michael", "Hahsler", role = c("aut", "cre", "cph"),
email = "[email protected]",
Expand Down Expand Up @@ -36,6 +36,9 @@ Suggests: datasets,
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
Encoding: UTF-8
RoxygenNote: 7.2.3
Roxygen: list(markdown = TRUE)
URL: https://github.com/mhahsler/arulesViz
BugReports: https://github.com/mhahsler/arulesViz/issues
Copyright: (C) 2021 Michael Hahsler
65 changes: 30 additions & 35 deletions NAMESPACE
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
import("arules")
import("grid")
import("ggplot2")
#import("ggraph")
import("tibble")
import("tidyr")
# NOTE: dplyr has many NAMESPACE conflicts with arules so we use ::
#import("dplyr")
# Generated by roxygen2: do not edit by hand

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)
S3method(plot, grouped_matrix)

export("inspectDT")
S3method(inspectDT, default)
S3method(inspectDT, rules)
S3method(inspectDT, itemsets)
S3method(inspectDT, data.frame)

export(
"ruleExplorer",
"saveAsGraph",
"associations2igraph",
"rules2matrix",
"rules2groupedMatrix"
)
S3method(inspectDT,data.frame)
S3method(inspectDT,default)
S3method(inspectDT,itemsets)
S3method(inspectDT,rules)
S3method(plot,grouped_matrix)
S3method(plot,itemsets)
S3method(plot,rules)
export(associations2igraph)
export(guide_edge_colourbar)
export(inspectDT)
export(ruleExplorer)
export(rules2groupedMatrix)
export(rules2matrix)
export(saveAsGraph)
import(arules)
import(ggplot2)
import(grid)
import(tibble)
import(tidyr)
importFrom(ggraph,guide_edge_colourbar)
importFrom(graphics,axis)
importFrom(graphics,box)
importFrom(graphics,mtext)
importFrom(graphics,par)
importFrom(graphics,text)
importFrom(methods,as)
importFrom(methods,is)
importFrom(methods,new)
importFrom(stats,median)
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# arulesViz 1.5.2-1 (xx/xx/2023)

## Changes
* We use now roxygen for documentation

# arulesViz 1.5-2 (03/03/2023)

## Bugfixes
Expand Down
38 changes: 38 additions & 0 deletions R/AAA_arulesViz-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#' @title `r packageDescription("arulesViz")$Package`: `r packageDescription("arulesViz")$Title`
#'
#' @description `r sub("<[^>]+>", "", packageDescription("arulesViz")$Description)`
#'
#' @section Main Functions:
#'
#' * [`arulesViz::plot()`] plot association rules.
#' * [`inspectDT()`] for interactive rule tables.
#' * [`ruleExplorer()`] for interactive rule inspection with tables and graphs.
#'
#' @author Michael Hahsler
#'
#' @references
#' Hahsler M (2017). arulesViz: Interactive Visualization of Association Rules with R. R Journal, 9(2), 163–175. ISSN 2073-4859, \doi{10.32614/RJ-2017-047}.
#'
#' @docType package
#' @name arulesViz-package
#'
#' @import arules
#' @import grid
#' @import ggplot2
#' @import arules
#' @import tibble
#' @import tidyr

# NOTE: dplyr has many NAMESPACE conflicts with arules so we use ::
# import("dplyr")

#' @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
NULL
5 changes: 4 additions & 1 deletion R/graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
grDevices::rgb(.6, .6, .8, alpha))
}


#' @rdname saveAsGraph
#' @export
associations2igraph <- function(x, associationsAsNodes = TRUE) {
if (associationsAsNodes) associations2igraph_nodes(x)
else associations2igraph_edges(x)
Expand Down Expand Up @@ -179,4 +182,4 @@ graphplot <- function(x,
control = control,
...
))
}
}
2 changes: 1 addition & 1 deletion R/igraph.R
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ graph_igraph <- function(x,
sep = '')

if (control$engine == "graphviz") {
check_installed(c("Rgraphviz"), action = "stop", message = "Install package from Bioconductor at https://www.bioconductor.org/packages/release/bioc/html/Rgraphviz.html")
check_installed(c("Rgraphviz"), action = "stop", message = "Install package from Bioconductor at https://bioconductor.org/packages/Rgraphviz/")

gNEL <- igraph::igraph.to.graphNEL(g)

Expand Down
54 changes: 51 additions & 3 deletions R/inspectDT.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,59 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


# use library DT

#' Inspect Associations Interactively Using datatable
#'
#' Uses \pkg{datatable} to create a HTML table widget using the DataTables
#' library. Rules can be interactively filtered and sorted.
#'
#' @aliases inspect inspectDT datatable
#' @param x an object of class "rules" or "itemsets".
#' @param precision controls the precision used to print the quality measures (defaults to 2).
#' @param ... additional arguments are passed on to [`DT::datatable()`].
#' @return A datatable htmlwidget.
#' @author Michael Hahsler
#' @seealso \code{\link[DT]{datatable}} in \pkg{DT}.
#' @references Hahsler M (2017). arulesViz: Interactive Visualization of
#' Association Rules with R. \emph{R Journal,} 9(2):163-175. ISSN 2073-4859.
#' \doi{10.32614/RJ-2017-047}.
#' @keywords print
#' @examples
#'
#' \dontrun{
#' data(Groceries)
#' rules <- apriori(Groceries, parameter=list(support=0.005, confidence=0.5))
#' rules
#'
#' inspectDT(rules)
#'
#' # for more control on the data table, you can used DATAFRAME() to convert the rules.
#' rules_df <- DATAFRAME(rules, setStart = '', setEnd = '', itemSep = ' + ')
#' rules_df$count <- NULL
#' head(rules_df)
#' inspectDT(rules_df)
#'
#' # Save HTML widget as web page
#' p <- inspectDT(rules)
#' htmlwidgets::saveWidget(p, "arules.html", selfcontained = FALSE)
#' # Note: self-contained seems to make the browser slow.
#'
#' # inspect the widget
#' browseURL("arules.html")
#'
#' # clean up
#' unlink(c("arules.html", "arules_files"), recursive = TRUE)}
#'
#' @export
inspectDT <- function(x, ...)
UseMethod("inspectDT", x)

#' @rdname inspectDT
#' @export
inspectDT.default <- function(x, ...)
stop("inspect 2 not implemented for class ", class(x))

#' @rdname inspectDT
#' @export
inspectDT.rules <- function(x, precision = 3, ...) {
df <- DATAFRAME(x)
DT::datatable(df,
Expand All @@ -34,6 +78,8 @@ inspectDT.rules <- function(x, precision = 3, ...) {
DT::formatRound(columns = which(sapply(df, is.numeric)), digits = max(precision))
}

#' @rdname inspectDT
#' @export
inspectDT.itemsets <- function(x, precision = 3, ...) {
df <- DATAFRAME(x)
DT::datatable(df,
Expand All @@ -43,6 +89,8 @@ inspectDT.itemsets <- function(x, precision = 3, ...) {
DT::formatRound(columns = which(sapply(df, is.numeric)), digits = max(precision))
}

#' @rdname inspectDT
#' @export
inspectDT.data.frame <- function(x, precision = 3, ...) {
df <- x
DT::datatable(df,
Expand Down
Loading

0 comments on commit f8735af

Please sign in to comment.