From 10a7cefdca760e1cd19cb94bb2e4701e862cf469 Mon Sep 17 00:00:00 2001 From: James J Balamuta Date: Thu, 11 Jan 2024 02:35:58 -0800 Subject: [PATCH] Add missing importFrom statements related to graphics. Fix option naming in documentation Address ggplot2's global variable name scope hiccup... --- NAMESPACE | 4 ++++ R/matrix.R | 9 ++++++--- man/draw-matrix.Rd | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index e562c93..faa14bc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,5 +2,9 @@ export(draw_matrix) export(gdraw_matrix) +importFrom(graphics,mtext) +importFrom(graphics,par) +importFrom(graphics,plot.new) +importFrom(graphics,plot.window) importFrom(graphics,rect) importFrom(graphics,text) diff --git a/R/matrix.R b/R/matrix.R index e7a5d75..216d12b 100644 --- a/R/matrix.R +++ b/R/matrix.R @@ -12,7 +12,7 @@ #' cells should be filled. Default: None. #' @param highlight_color Color to use to fill the background of a cell. #' -#' @importFrom graphics rect text +#' @importFrom graphics rect text mtext par plot.new plot.window #' @rdname draw-matrix #' @export #' @examples @@ -23,7 +23,7 @@ #' draw_matrix(mat_3x3) #' #' # Disable the indices -#' draw_matrix(mat_3x3, show_indices = FALSE) +#' draw_matrix(mat_3x3, show_cell_indices = FALSE) #' #' # Highlight a row #' mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) @@ -138,7 +138,7 @@ draw_matrix <- function( #' gdraw_matrix(mat_3x3) #' #' # View the matrix without indices present -#' gdraw_matrix(mat_3x3, show_indices = FALSE) +#' gdraw_matrix(mat_3x3, show_cell_indices = FALSE) #' #' # Highlight a row #' mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) @@ -157,6 +157,9 @@ gdraw_matrix <- function( highlight_color = "lemonchiffon" ) { + # Define a value to avoid using the .data pronoun and incorporate rlang... + highlight = value = NULL + if(!requireNamespace("ggplot2", quietly = TRUE)) { stop("Please make sure `ggplot2` is installed to use this function.") } diff --git a/man/draw-matrix.Rd b/man/draw-matrix.Rd index 11c50c9..976861b 100644 --- a/man/draw-matrix.Rd +++ b/man/draw-matrix.Rd @@ -48,7 +48,7 @@ mat_3x3 = matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3) draw_matrix(mat_3x3) # Disable the indices -draw_matrix(mat_3x3, show_indices = FALSE) +draw_matrix(mat_3x3, show_cell_indices = FALSE) # Highlight a row mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2) @@ -65,7 +65,7 @@ mat_3x3 = matrix(c(10, 200, -30, 40, 500, 30, 90, -55, 10), ncol = 3) gdraw_matrix(mat_3x3) # View the matrix without indices present -gdraw_matrix(mat_3x3, show_indices = FALSE) +gdraw_matrix(mat_3x3, show_cell_indices = FALSE) # Highlight a row mat_2x2 = matrix(c(1, 2, 3, 4), nrow = 2)