diff --git a/R/drawTreemap.R b/R/drawTreemap.R index 02a4d8f..78e2d35 100644 --- a/R/drawTreemap.R +++ b/R/drawTreemap.R @@ -75,41 +75,44 @@ #' the input for the drawing function #' #' @examples -#' # load example data -#' data(mtcars) -#' mtcars$car_name = gsub(" ", "\n", row.names(mtcars)) +#' # load package +#' library(WeightedTreemaps) #' -#' # generate treemap; set seed to obtain same pattern every time +#' # generate dummy data +#' df <- data.frame( +#' A = rep(c("abcd", "efgh"), each = 4), +#' B = letters[1:8], +#' size = c(37, 52, 58, 27, 49, 44, 34, 45) +#' ) +#' +#' # compute treemap #' tm <- voronoiTreemap( -#' data = mtcars, -#' levels = c("gear", "car_name"), -#' cell_size = "wt", -#' shape = "rounded_rect", +#' data = df, +#' levels = c("B"), +#' cell_size = "size", +#' shape = "circle", +#' positioning = "regular", #' seed = 123 #' ) #' -#' # draw treemap -#' drawTreemap(tm, label_size = 2) +#' # plot treemap with each cell colored by name (default) +#' drawTreemap(tm, label_size = 1, color_type = "categorical") #' -#' # draw different variants of the same treemap on one page using -#' # the 'layout' and 'position' arguments (indicating rows and columns) -#' drawTreemap(tm, title = "treemap 1", label_size = 2, -#' color_type = "categorical", color_level = 1, -#' layout = c(1,3), position = c(1, 1)) +#' # plot treemap with each cell colored by name, but larger cells +#' # lighter and smaller cells darker +#' drawTreemap(tm, label_size = 1, color_type = "both") #' -#' drawTreemap(tm, title = "treemap 2", label_size = 2, -#' color_type = "categorical", color_level = 2, border_size = 3, -#' add = TRUE, layout = c(1,3), position = c(1, 2)) -#' -#' drawTreemap(tm, title = "treemap 3", label_size = 2, -#' color_type = "cell_size", color_level = 2, -#' color_palette = heat.colors(10), -#' border_color = grey(0.4), label_color = grey(0.4), -#' add = TRUE, layout = c(1,3), position = c(1, 3), -#' title_color = "black") +#' # plot treemap with different color palette and style +#' drawTreemap(tm, label_size = 1, label_color = grey(0.3), +#' border_color = grey(0.3), color_palette = heat.colors(6) +#' ) #' #' # --------------------------------------------- #' +#' # load example data +#' data(mtcars) +#' mtcars$car_name = gsub(" ", "\n", row.names(mtcars)) +#' #' # generate sunburst treemap #' tm <- sunburstTreemap( #' data = mtcars, diff --git a/R/voronoiTreemap.R b/R/voronoiTreemap.R index 6bb06a6..17507ca 100644 --- a/R/voronoiTreemap.R +++ b/R/voronoiTreemap.R @@ -81,38 +81,37 @@ #' @seealso \code{\link{drawTreemap}} for drawing the treemap. #' #' @examples -#' # load example data -#' data(mtcars) -#' mtcars$car_name = gsub(" ", "\n", row.names(mtcars)) +#' # load package +#' library(WeightedTreemaps) #' -#' # generate treemap; set seed to obtain same pattern every time +#' # generate dummy data +#' df <- data.frame( +#' A = rep(c("abcd", "efgh"), each = 4), +#' B = letters[1:8], +#' size = c(37, 52, 58, 27, 49, 44, 34, 45) +#' ) +#' +#' # compute treemap #' tm <- voronoiTreemap( -#' data = mtcars, -#' levels = c("gear", "car_name"), -#' cell_size = "wt", -#' shape = "rounded_rect", +#' data = df, +#' levels = c("B"), +#' cell_size = "size", +#' shape = "circle", +#' positioning = "regular", #' seed = 123 #' ) #' -#' # draw treemap -#' drawTreemap(tm, label_size = 2) +#' # plot treemap with each cell colored by name (default) +#' drawTreemap(tm, label_size = 1, color_type = "categorical") #' -#' # draw different variants of the same treemap on one page using -#' # the 'layout' and 'position' arguments (indicating rows and columns) -#' drawTreemap(tm, title = "treemap 1", label_size = 2, -#' color_type = "categorical", color_level = 1, -#' layout = c(1,3), position = c(1, 1)) +#' # plot treemap with each cell colored by name, but larger cells +#' # lighter and smaller cells darker +#' drawTreemap(tm, label_size = 1, color_type = "both") #' -#' drawTreemap(tm, title = "treemap 2", label_size = 2, -#' color_type = "categorical", color_level = 2, border_size = 3, -#' add = TRUE, layout = c(1,3), position = c(1, 2)) -#' -#' drawTreemap(tm, title = "treemap 3", label_size = 2, -#' color_type = "cell_size", color_level = 2, -#' color_palette = heat.colors(10), -#' border_color = grey(0.4), label_color = grey(0.4), -#' add = TRUE, layout = c(1,3), position = c(1, 3), -#' title_color = "black") +#' # plot treemap with different color palette and style +#' drawTreemap(tm, label_size = 1, label_color = grey(0.3), +#' border_color = grey(0.3), color_palette = heat.colors(6) +#' ) #' #' @importFrom Rcpp evalCpp #' @importFrom grid grid.newpage diff --git a/README.Rmd b/README.Rmd index d7cd7c3..d1b3dfa 100644 --- a/README.Rmd +++ b/README.Rmd @@ -1,7 +1,7 @@ --- output: github_document title: "WeightedTreemaps" -author: "Michael Jahn, David Leslie, Ahmadou Dicko" +author: "Michael Jahn, David Leslie, Ahmadou Dicko, Paul Murrell" date: "`r Sys.Date()`" vignette: > %\VignetteIndexEntry{WeightedTreemaps} diff --git a/README.md b/README.md index 892f6c2..61e8ec7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ WeightedTreemaps ================ -Michael Jahn, David Leslie, Ahmadou Dicko -2023-12-15 +Michael Jahn, David Leslie, Ahmadou Dicko, Paul Murrell +2024-01-07 diff --git a/cran-comments.md b/cran-comments.md index a115d8f..e2f10e7 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,4 +1,4 @@ -## Release +## Update ## Test environments @@ -10,13 +10,13 @@ - ubuntu-latest (release) - ubuntu-latest (oldrel-1) - ### with `rhub::check_for_cran()` - Fedora Linux, R-devel, clang, gfortran - Debian Linux, R-release, GCC - Windows Server 2022, R-devel, 64 bit - Ubuntu Linux 20.04.1 LTS, R-release, GCC +- Debian Linux, R-devel, GCC ASAN/UBSAN ## R CMD check results @@ -34,6 +34,9 @@ checking installed package size ... NOTE Installed package size exceeding 5 MB is caused by the compiled function `voronoiDiagram.o`. The size of this file can not be reduced. +There were "additional issues" brought up with from ASAN/UBSAN sanitizer checks. +These were fixed in the current version. + ## Downstream dependencies - There are currently no downstream dependencies for this package diff --git a/man/drawTreemap.Rd b/man/drawTreemap.Rd index 9f43f87..ea7ad9a 100644 --- a/man/drawTreemap.Rd +++ b/man/drawTreemap.Rd @@ -127,41 +127,44 @@ during treemap generation. Such parameters are primarily cell size and initial shape of the treemap. } \examples{ -# load example data -data(mtcars) -mtcars$car_name = gsub(" ", "\n", row.names(mtcars)) +# load package +library(WeightedTreemaps) + +# generate dummy data +df <- data.frame( + A = rep(c("abcd", "efgh"), each = 4), + B = letters[1:8], + size = c(37, 52, 58, 27, 49, 44, 34, 45) +) -# generate treemap; set seed to obtain same pattern every time +# compute treemap tm <- voronoiTreemap( - data = mtcars, - levels = c("gear", "car_name"), - cell_size = "wt", - shape = "rounded_rect", + data = df, + levels = c("B"), + cell_size = "size", + shape = "circle", + positioning = "regular", seed = 123 ) -# draw treemap -drawTreemap(tm, label_size = 2) - -# draw different variants of the same treemap on one page using -# the 'layout' and 'position' arguments (indicating rows and columns) -drawTreemap(tm, title = "treemap 1", label_size = 2, - color_type = "categorical", color_level = 1, - layout = c(1,3), position = c(1, 1)) +# plot treemap with each cell colored by name (default) +drawTreemap(tm, label_size = 1, color_type = "categorical") -drawTreemap(tm, title = "treemap 2", label_size = 2, - color_type = "categorical", color_level = 2, border_size = 3, - add = TRUE, layout = c(1,3), position = c(1, 2)) +# plot treemap with each cell colored by name, but larger cells +# lighter and smaller cells darker +drawTreemap(tm, label_size = 1, color_type = "both") -drawTreemap(tm, title = "treemap 3", label_size = 2, - color_type = "cell_size", color_level = 2, - color_palette = heat.colors(10), - border_color = grey(0.4), label_color = grey(0.4), - add = TRUE, layout = c(1,3), position = c(1, 3), - title_color = "black") +# plot treemap with different color palette and style +drawTreemap(tm, label_size = 1, label_color = grey(0.3), + border_color = grey(0.3), color_palette = heat.colors(6) +) # --------------------------------------------- +# load example data +data(mtcars) +mtcars$car_name = gsub(" ", "\n", row.names(mtcars)) + # generate sunburst treemap tm <- sunburstTreemap( data = mtcars, diff --git a/man/voronoiTreemap.Rd b/man/voronoiTreemap.Rd index 9aa79b6..c7e5a10 100644 --- a/man/voronoiTreemap.Rd +++ b/man/voronoiTreemap.Rd @@ -116,38 +116,37 @@ This function returns a treemap object instead of a plot. In order to actually draw the treemap, use \code{\link{drawTreemap}}. } \examples{ -# load example data -data(mtcars) -mtcars$car_name = gsub(" ", "\n", row.names(mtcars)) +# load package +library(WeightedTreemaps) + +# generate dummy data +df <- data.frame( + A = rep(c("abcd", "efgh"), each = 4), + B = letters[1:8], + size = c(37, 52, 58, 27, 49, 44, 34, 45) +) -# generate treemap; set seed to obtain same pattern every time +# compute treemap tm <- voronoiTreemap( - data = mtcars, - levels = c("gear", "car_name"), - cell_size = "wt", - shape = "rounded_rect", + data = df, + levels = c("B"), + cell_size = "size", + shape = "circle", + positioning = "regular", seed = 123 ) -# draw treemap -drawTreemap(tm, label_size = 2) - -# draw different variants of the same treemap on one page using -# the 'layout' and 'position' arguments (indicating rows and columns) -drawTreemap(tm, title = "treemap 1", label_size = 2, - color_type = "categorical", color_level = 1, - layout = c(1,3), position = c(1, 1)) - -drawTreemap(tm, title = "treemap 2", label_size = 2, - color_type = "categorical", color_level = 2, border_size = 3, - add = TRUE, layout = c(1,3), position = c(1, 2)) - -drawTreemap(tm, title = "treemap 3", label_size = 2, - color_type = "cell_size", color_level = 2, - color_palette = heat.colors(10), - border_color = grey(0.4), label_color = grey(0.4), - add = TRUE, layout = c(1,3), position = c(1, 3), - title_color = "black") +# plot treemap with each cell colored by name (default) +drawTreemap(tm, label_size = 1, color_type = "categorical") + +# plot treemap with each cell colored by name, but larger cells +# lighter and smaller cells darker +drawTreemap(tm, label_size = 1, color_type = "both") + +# plot treemap with different color palette and style +drawTreemap(tm, label_size = 1, label_color = grey(0.3), + border_color = grey(0.3), color_palette = heat.colors(6) +) } \seealso{