From 5f47d4cf5aa147c9f310e2917e566d2480ddd527 Mon Sep 17 00:00:00 2001 From: ericarcher Date: Sun, 8 Jun 2025 11:38:25 -0700 Subject: [PATCH 1/4] v2.5.5 to CRAN switch to SWFSC/rfPermute as main --- .Rbuildignore | 0 .github/.gitignore | 0 .github/workflows/R-CMD-check.yaml | 0 DESCRIPTION | 9 ++++----- NAMESPACE | 1 - R/balancedSampsize.R | 0 R/casePredictions.R | 0 R/classPriors.R | 0 R/cleanRFdata.R | 0 R/confusionMatrix.R | 16 ++++++++-------- R/dataSets.R | 0 R/importance.R | 14 +++++++------- R/internals.R | 0 R/pctCorrect.R | 0 R/plotImpPreds.R | 8 ++++---- R/plotInbag.R | 0 R/plotNull.R | 16 ++++++++-------- R/plotPredictedProbs.R | 14 +++++++------- R/plotProximity.R | 8 ++++---- R/plotTrace.R | 12 ++++++------ R/plotVotes.R | 0 R/rfPermute-package.R | 1 - R/rfPermute.R | 1 - R/summary.R | 0 README.md | 4 ++++ appveyor.yml | 0 data/symb.metab.rda | Bin inst/rfPermute_Tutorial.html | 0 man/balancedSampsize.Rd | 0 man/casePredictions.Rd | 0 man/classPriors.Rd | 0 man/cleanRFdata.Rd | 0 man/combineRP.Rd | 0 man/confusionMatrix.Rd | 0 man/importance.Rd | 0 man/pctCorrect.Rd | 0 man/plotImpPreds.Rd | 0 man/plotInbag.Rd | 0 man/plotNull.Rd | 0 man/plotPredictedProbs.Rd | 0 man/plotProximity.Rd | 0 man/plotTrace.Rd | 0 man/plotVotes.Rd | 0 man/rfPermute-package.Rd | 6 +++--- man/summary.Rd | 0 man/symb.metab.Rd | 0 46 files changed, 55 insertions(+), 55 deletions(-) mode change 100644 => 100755 .Rbuildignore mode change 100644 => 100755 .github/.gitignore mode change 100644 => 100755 .github/workflows/R-CMD-check.yaml mode change 100644 => 100755 DESCRIPTION mode change 100644 => 100755 R/balancedSampsize.R mode change 100644 => 100755 R/casePredictions.R mode change 100644 => 100755 R/classPriors.R mode change 100644 => 100755 R/cleanRFdata.R mode change 100644 => 100755 R/confusionMatrix.R mode change 100644 => 100755 R/dataSets.R mode change 100644 => 100755 R/importance.R mode change 100644 => 100755 R/internals.R mode change 100644 => 100755 R/pctCorrect.R mode change 100644 => 100755 R/plotImpPreds.R mode change 100644 => 100755 R/plotInbag.R mode change 100644 => 100755 R/plotNull.R mode change 100644 => 100755 R/plotPredictedProbs.R mode change 100644 => 100755 R/plotProximity.R mode change 100644 => 100755 R/plotTrace.R mode change 100644 => 100755 R/plotVotes.R mode change 100644 => 100755 R/rfPermute-package.R mode change 100644 => 100755 R/summary.R mode change 100644 => 100755 appveyor.yml mode change 100644 => 100755 data/symb.metab.rda mode change 100644 => 100755 inst/rfPermute_Tutorial.html mode change 100644 => 100755 man/balancedSampsize.Rd mode change 100644 => 100755 man/casePredictions.Rd mode change 100644 => 100755 man/classPriors.Rd mode change 100644 => 100755 man/cleanRFdata.Rd mode change 100644 => 100755 man/combineRP.Rd mode change 100644 => 100755 man/confusionMatrix.Rd mode change 100644 => 100755 man/importance.Rd mode change 100644 => 100755 man/pctCorrect.Rd mode change 100644 => 100755 man/plotImpPreds.Rd mode change 100644 => 100755 man/plotInbag.Rd mode change 100644 => 100755 man/plotNull.Rd mode change 100644 => 100755 man/plotPredictedProbs.Rd mode change 100644 => 100755 man/plotProximity.Rd mode change 100644 => 100755 man/plotTrace.Rd mode change 100644 => 100755 man/plotVotes.Rd mode change 100644 => 100755 man/rfPermute-package.Rd mode change 100644 => 100755 man/summary.Rd mode change 100644 => 100755 man/symb.metab.Rd diff --git a/.Rbuildignore b/.Rbuildignore old mode 100644 new mode 100755 diff --git a/.github/.gitignore b/.github/.gitignore old mode 100644 new mode 100755 diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml old mode 100644 new mode 100755 diff --git a/DESCRIPTION b/DESCRIPTION old mode 100644 new mode 100755 index dba61d1..041d434 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,11 +7,11 @@ Description: Estimate significance of importance metrics metrics for each predictor variable and p-value of observed. Provides summary and visualization functions for 'randomForest' results. -Version: 2.5.4 +Version: 2.5.5 Authors@R: c( - EA = person("Eric", "Archer", email = "eric.archer@noaa.gov", role = c("aut", "cre"))) -URL: https://github.com/EricArcher/rfPermute -BugReports: https://github.com/EricArcher/rfPermute/issues + EA = person("Eric", "Archer", email = "eric.ivan.archer@gmail.com", role = c("aut", "cre"))) +URL: https://github.com/SWFSC/rfPermute +BugReports: https://github.com/SWFSC/rfPermute/issues Depends: R (>= 4.1.0) Imports: @@ -20,7 +20,6 @@ Imports: ggplot2 (>= 3.3), grDevices, gridExtra, - magrittr (>= 2.0), methods, parallel, randomForest (>= 4.6), diff --git a/NAMESPACE b/NAMESPACE index d06f4cb..c743829 100755 --- a/NAMESPACE +++ b/NAMESPACE @@ -27,7 +27,6 @@ export(plotTrace) export(plotVotes) export(rfPermute) export(rfPermuteTutorial) -importFrom(magrittr,"%>%") importFrom(methods,new) importFrom(randomForest,importance) importFrom(randomForest,randomForest) diff --git a/R/balancedSampsize.R b/R/balancedSampsize.R old mode 100644 new mode 100755 diff --git a/R/casePredictions.R b/R/casePredictions.R old mode 100644 new mode 100755 diff --git a/R/classPriors.R b/R/classPriors.R old mode 100644 new mode 100755 diff --git a/R/cleanRFdata.R b/R/cleanRFdata.R old mode 100644 new mode 100755 diff --git a/R/confusionMatrix.R b/R/confusionMatrix.R old mode 100644 new mode 100755 index 3f7f731..27f92e3 --- a/R/confusionMatrix.R +++ b/R/confusionMatrix.R @@ -88,8 +88,8 @@ plotConfMat <- function(x, title = NULL, plot = TRUE) { if(rf$type == "regression") stop("'rf' must be of a classification model") conf <- .confMat(rf) - pct.correct <- (100 * sum(diag(conf)) / sum(conf)) %>% - round(0) %>% + pct.correct <- (100 * sum(diag(conf)) / sum(conf)) |> + round(0) |> paste0("% correct") title <- if(is.null(title)) { pct.correct @@ -99,16 +99,16 @@ plotConfMat <- function(x, title = NULL, plot = TRUE) { freq <- rowSums(conf) rownames(conf) <- paste0(names(freq), " (", freq, ")") - p <- conf %>% - prop.table(1) %>% - as.data.frame %>% - tibble::rownames_to_column("observed") %>% - tidyr::gather("predicted", "prop", -.data$observed) %>% + p <- conf |> + prop.table(1) |> + as.data.frame() |> + tibble::rownames_to_column("observed") |> + tidyr::gather("predicted", "prop", -.data$observed) |> dplyr::mutate( observed = factor(.data$observed), observed = stats::reorder(.data$observed, dplyr::desc(.data$observed)), predicted = factor(.data$predicted) - ) %>% + ) |> ggplot2::ggplot(ggplot2::aes_string("predicted", "observed")) + ggplot2::geom_raster(ggplot2::aes_string(fill = "prop")) + ggplot2::scale_fill_viridis_c( diff --git a/R/dataSets.R b/R/dataSets.R old mode 100644 new mode 100755 diff --git a/R/importance.R b/R/importance.R old mode 100644 new mode 100755 index 25128a9..a30681d --- a/R/importance.R +++ b/R/importance.R @@ -137,12 +137,12 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, pval = if(inherits(x, "rfPermute")) { x$pval[rownames(imp.mat), i, sc] } else Inf - ) %>% - tibble::rownames_to_column("pred") %>% + ) |> + tibble::rownames_to_column("pred") |> dplyr::mutate( is.sig = .data$pval <= alpha, pred = stats::reorder(.data$pred, .data$imp) - ) %>% + ) |> dplyr::arrange(-.data$imp) if(sig.only) imp.df <- imp.df[imp.df$is.sig, ] n <- min(n, nrow(imp.df)) @@ -174,9 +174,9 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, preds <- rev(rev(preds)[1:n]) imp.df <- data.frame(imp.mat[preds, imp.type, drop = FALSE], check.names = FALSE) if(ranks) for(i in imp.type) imp.df[[i]] <- rank(-imp.df[[i]]) - imp.df <- imp.df %>% - tibble::rownames_to_column("pred") %>% - tidyr::pivot_longer(-.data$pred, names_to = "type") %>% + imp.df <- imp.df |> + tibble::rownames_to_column("pred") |> + tidyr::pivot_longer(-.data$pred, names_to = "type") |> dplyr::mutate( type = factor(.data$type, levels = imp.type), pred = factor(.data$pred, levels = preds) @@ -236,4 +236,4 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, } } invisible(imp.plot) -} \ No newline at end of file +} diff --git a/R/internals.R b/R/internals.R old mode 100644 new mode 100755 diff --git a/R/pctCorrect.R b/R/pctCorrect.R old mode 100644 new mode 100755 diff --git a/R/plotImpPreds.R b/R/plotImpPreds.R old mode 100644 new mode 100755 index 31a34a5..a867b32 --- a/R/plotImpPreds.R +++ b/R/plotImpPreds.R @@ -68,9 +68,9 @@ plotImpPreds <- function(x, df, class.col, imp.type = NULL, max.vars = 16, df$.class. <- factor(df[[class.col]]) df <- df[, c(".class.", imp.vars)] - p <- df %>% - tidyr::pivot_longer(-.data$.class., names_to = "var") %>% - dplyr::mutate(var = factor(.data$var, levels = imp.vars)) %>% + p <- df |> + tidyr::pivot_longer(-.data$.class., names_to = "var") |> + dplyr::mutate(var = factor(.data$var, levels = imp.vars)) |> ggplot2::ggplot(ggplot2::aes_string(".class.", "value")) + ggplot2::geom_violin(alpha = violin.alpha) + ggplot2::geom_jitter(size = size, alpha = point.alpha, width = 0.25, height = 0) + @@ -80,4 +80,4 @@ plotImpPreds <- function(x, df, class.col, imp.type = NULL, max.vars = 16, if(plot) print(p) invisible(p) -} \ No newline at end of file +} diff --git a/R/plotInbag.R b/R/plotInbag.R old mode 100644 new mode 100755 diff --git a/R/plotNull.R b/R/plotNull.R old mode 100644 new mode 100755 index a1ef574..585938c --- a/R/plotNull.R +++ b/R/plotNull.R @@ -65,14 +65,14 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, imp.type ) - df <- sapply(imp.type, function(i) x$null.dist[[sc]][pr, i, ]) %>% - as.data.frame() %>% - tidyr::gather("imp.type", "importance") %>% + df <- sapply(imp.type, function(i) x$null.dist[[sc]][pr, i, ]) |> + as.data.frame() |> + tidyr::gather("imp.type", "importance") |> dplyr::mutate(imp.type = factor(labels[imp.type], levels = labels)) - obs <- imp[pr, imp.type, drop = FALSE] %>% - as.data.frame() %>% - tibble::rownames_to_column("predictor") %>% - tidyr::gather("imp.type", "importance", -.data$predictor) %>% + obs <- imp[pr, imp.type, drop = FALSE] |> + as.data.frame() |> + tibble::rownames_to_column("predictor") |> + tidyr::gather("imp.type", "importance", -.data$predictor) |> dplyr::mutate(imp.type = factor(labels[imp.type], levels = labels)) p <- ggplot2::ggplot(df, ggplot2::aes_string("importance")) @@ -93,4 +93,4 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, if(plot) for(p in g) print(p) invisible(g) -} \ No newline at end of file +} diff --git a/R/plotPredictedProbs.R b/R/plotPredictedProbs.R old mode 100644 new mode 100755 index 39e6603..89229a2 --- a/R/plotPredictedProbs.R +++ b/R/plotPredictedProbs.R @@ -25,15 +25,15 @@ plotPredictedProbs <- function(x, bins = 30, plot = TRUE) { rf <- as.randomForest(x) if(rf$type == "regression") stop("'rf' must be of a classification model") - p <- rf$votes %>% - as.data.frame %>% + p <- rf$votes |> + as.data.frame() |> cbind( class = as.character(rf$y), predicted = as.character(rf$predicted) - ) %>% - tidyr::gather("pred.class", "prob", -.data$class, -.data$predicted) %>% - dplyr::filter(.data$predicted == .data$pred.class) %>% - dplyr::mutate(correct = .data$class == .data$predicted) %>% + ) |> + tidyr::gather("pred.class", "prob", -.data$class, -.data$predicted) |> + dplyr::filter(.data$predicted == .data$pred.class) |> + dplyr::mutate(correct = .data$class == .data$predicted) |> ggplot2::ggplot(ggplot2::aes_string("prob", fill = "class")) + ggplot2::geom_histogram(bins = bins) + ggplot2::facet_wrap(~ predicted) + @@ -42,4 +42,4 @@ plotPredictedProbs <- function(x, bins = 30, plot = TRUE) { if(plot) print(p) invisible(p) -} \ No newline at end of file +} diff --git a/R/plotProximity.R b/R/plotProximity.R old mode 100644 new mode 100755 index edf2da6..cd3d601 --- a/R/plotProximity.R +++ b/R/plotProximity.R @@ -153,12 +153,12 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, if(legend.type == "label") { g <- g + ggplot2::geom_label( ggplot2::aes_(label = ~class), - data = mds.df %>% - dplyr::group_by(.data$class) %>% + data = mds.df |> + dplyr::group_by(.data$class) |> dplyr::summarize( x = mean(.data$x), y = mean(.data$y) - ) %>% + ) |> dplyr::ungroup(), fill = "white", alpha = label.alpha, @@ -193,4 +193,4 @@ plotProximity <- function(x, dim.x = 1, dim.y = 2, class.cols = NULL, if(plot) print(g) invisible(list(prox.mds = prox.mds, g = g)) -} \ No newline at end of file +} diff --git a/R/plotTrace.R b/R/plotTrace.R old mode 100644 new mode 100755 index 7688a70..77a6ffc --- a/R/plotTrace.R +++ b/R/plotTrace.R @@ -28,13 +28,13 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { names(class.cols) <- names(class.lines) <- c("OOB", levels(rf$y)) df <- as.data.frame(rf$err.rate) - df %>% - dplyr::mutate(trees = 1:dplyr::n()) %>% - tidyr::gather("class", "error", -.data$trees) %>% + df |> + dplyr::mutate(trees = 1:dplyr::n()) |> + tidyr::gather("class", "error", -.data$trees) |> dplyr::mutate( class = factor(.data$class, levels = colnames(df)), error = if(pct.correct) (1 - .data$error) * 100 else .data$error * 100 - ) %>% + ) |> ggplot2::ggplot(ggplot2::aes_string("trees", "error", color = "class")) + ggplot2::geom_line(ggplot2::aes_string(linetype = "class")) + ggplot2::scale_color_manual(values = class.cols) + @@ -45,7 +45,7 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { ) + ggplot2::theme(legend.title = ggplot2::element_blank()) } else if(utils::hasName(rf, "mse")) { - data.frame(trees = 1:length(rf$mse), error = rf$mse) %>% + data.frame(trees = 1:length(rf$mse), error = rf$mse) |> ggplot2::ggplot(ggplot2::aes_string("trees", "error")) + ggplot2::geom_line() + ggplot2::labs(x = "Trees", y = "Mean Squared Error") @@ -59,4 +59,4 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { } if(plot) print(p) invisible(p) -} \ No newline at end of file +} diff --git a/R/plotVotes.R b/R/plotVotes.R old mode 100644 new mode 100755 diff --git a/R/rfPermute-package.R b/R/rfPermute-package.R old mode 100644 new mode 100755 index ff7d5b6..4823b5a --- a/R/rfPermute-package.R +++ b/R/rfPermute-package.R @@ -8,7 +8,6 @@ #' #' @importFrom randomForest randomForest #' @importFrom rlang .data -#' @importFrom magrittr %>% #' @importFrom methods new #' .onAttach <- function(libname, pkgname) { diff --git a/R/rfPermute.R b/R/rfPermute.R index f0110eb..af4a3ef 100755 --- a/R/rfPermute.R +++ b/R/rfPermute.R @@ -270,7 +270,6 @@ predict.rfPermute <- function(object, ...) predict(as.randomForest(object), ...) #' @rdname rfPermute -#' @importFrom stats predict #' @export #' rfPermuteTutorial <- function() { diff --git a/R/summary.R b/R/summary.R old mode 100644 new mode 100755 diff --git a/README.md b/README.md index 8aa827c..248c065 100755 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ devtools::install_github('EricArcher/rfPermute') ## Changelog +### version 2.5.5 (on CRAN) + +* move of package to SWFSC/rfPermute as main GitHub repository + ### version 2.5.4 (on CRAN) * fixed print.rfPermute output for regression models. diff --git a/appveyor.yml b/appveyor.yml old mode 100644 new mode 100755 diff --git a/data/symb.metab.rda b/data/symb.metab.rda old mode 100644 new mode 100755 diff --git a/inst/rfPermute_Tutorial.html b/inst/rfPermute_Tutorial.html old mode 100644 new mode 100755 diff --git a/man/balancedSampsize.Rd b/man/balancedSampsize.Rd old mode 100644 new mode 100755 diff --git a/man/casePredictions.Rd b/man/casePredictions.Rd old mode 100644 new mode 100755 diff --git a/man/classPriors.Rd b/man/classPriors.Rd old mode 100644 new mode 100755 diff --git a/man/cleanRFdata.Rd b/man/cleanRFdata.Rd old mode 100644 new mode 100755 diff --git a/man/combineRP.Rd b/man/combineRP.Rd old mode 100644 new mode 100755 diff --git a/man/confusionMatrix.Rd b/man/confusionMatrix.Rd old mode 100644 new mode 100755 diff --git a/man/importance.Rd b/man/importance.Rd old mode 100644 new mode 100755 diff --git a/man/pctCorrect.Rd b/man/pctCorrect.Rd old mode 100644 new mode 100755 diff --git a/man/plotImpPreds.Rd b/man/plotImpPreds.Rd old mode 100644 new mode 100755 diff --git a/man/plotInbag.Rd b/man/plotInbag.Rd old mode 100644 new mode 100755 diff --git a/man/plotNull.Rd b/man/plotNull.Rd old mode 100644 new mode 100755 diff --git a/man/plotPredictedProbs.Rd b/man/plotPredictedProbs.Rd old mode 100644 new mode 100755 diff --git a/man/plotProximity.Rd b/man/plotProximity.Rd old mode 100644 new mode 100755 diff --git a/man/plotTrace.Rd b/man/plotTrace.Rd old mode 100644 new mode 100755 diff --git a/man/plotVotes.Rd b/man/plotVotes.Rd old mode 100644 new mode 100755 diff --git a/man/rfPermute-package.Rd b/man/rfPermute-package.Rd old mode 100644 new mode 100755 index 67f3e2e..8f34525 --- a/man/rfPermute-package.Rd +++ b/man/rfPermute-package.Rd @@ -10,13 +10,13 @@ Random Forest Predictor Importance Significance and Model Diagnostics. \seealso{ Useful links: \itemize{ - \item \url{https://github.com/EricArcher/rfPermute} - \item Report bugs at \url{https://github.com/EricArcher/rfPermute/issues} + \item \url{https://github.com/SWFSC/rfPermute} + \item Report bugs at \url{https://github.com/SWFSC/rfPermute/issues} } } \author{ -\strong{Maintainer}: Eric Archer \email{eric.archer@noaa.gov} +\strong{Maintainer}: Eric Archer \email{eric.ivan.archer@gmail.com} } \keyword{internal} diff --git a/man/summary.Rd b/man/summary.Rd old mode 100644 new mode 100755 diff --git a/man/symb.metab.Rd b/man/symb.metab.Rd old mode 100644 new mode 100755 From 5f516c4afcb13dbd8ac788a361cfcb4ee708d949 Mon Sep 17 00:00:00 2001 From: ericarcher Date: Tue, 10 Jun 2025 10:09:32 -0700 Subject: [PATCH 2/4] v2.5.5 on CRAN --- .Rbuildignore | 3 ++- CRAN-SUBMISSION | 3 +++ README.md | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 CRAN-SUBMISSION diff --git a/.Rbuildignore b/.Rbuildignore index 7ef3a46..9fd098b 100755 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -10,4 +10,5 @@ tar.gz$ ^appveyor\.yml$ ^\.github$ .DS_Store -^revdep$ \ No newline at end of file +^revdep$ +^CRAN-SUBMISSION$ diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..fbdcfac --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 2.5.5 +Date: 2025-06-08 18:57:19 UTC +SHA: 5f47d4cf5aa147c9f310e2917e566d2480ddd527 diff --git a/README.md b/README.md index 248c065..b8873a7 100755 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ devtools::install_github('EricArcher/rfPermute') * move of package to SWFSC/rfPermute as main GitHub repository -### version 2.5.4 (on CRAN) +### version 2.5.4 * fixed print.rfPermute output for regression models. From ec35fc8ea178280e7a607b8f48dedd3f783745e4 Mon Sep 17 00:00:00 2001 From: ericarcher Date: Mon, 6 Oct 2025 22:59:42 -0700 Subject: [PATCH 3/4] remove aes_string() --- DESCRIPTION | 2 +- R/confusionMatrix.R | 4 ++-- R/importance.R | 6 +++--- R/plotImpPreds.R | 2 +- R/plotInbag.R | 2 +- R/plotNull.R | 4 ++-- R/plotPredictedProbs.R | 2 +- R/plotTrace.R | 8 +++++--- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 041d434..4053950 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,4 +54,4 @@ Collate: LazyData: TRUE License: GPL (>= 2) Encoding: UTF-8 -RoxygenNote: 7.3.2 +RoxygenNote: 7.3.3 diff --git a/R/confusionMatrix.R b/R/confusionMatrix.R index 27f92e3..f20df0f 100755 --- a/R/confusionMatrix.R +++ b/R/confusionMatrix.R @@ -109,8 +109,8 @@ plotConfMat <- function(x, title = NULL, plot = TRUE) { observed = stats::reorder(.data$observed, dplyr::desc(.data$observed)), predicted = factor(.data$predicted) ) |> - ggplot2::ggplot(ggplot2::aes_string("predicted", "observed")) + - ggplot2::geom_raster(ggplot2::aes_string(fill = "prop")) + + ggplot2::ggplot(ggplot2::aes(x = .data$predicted, y = .data$observed)) + + ggplot2::geom_raster(ggplot2::aes(fill = .data$prop)) + ggplot2::scale_fill_viridis_c( option = "magma", direction = -1, diff --git a/R/importance.R b/R/importance.R index a30681d..31c8f76 100755 --- a/R/importance.R +++ b/R/importance.R @@ -151,7 +151,7 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, ggplot2::ggplot( imp.df, - ggplot2::aes_string(x = "pred", y = "imp", fill = "is.sig") + ggplot2::aes(x = .data$pred, y = .data$imp, fill = .data$is.sig) ) + ggplot2::geom_bar(stat = "identity") + ggplot2::coord_flip() + @@ -183,8 +183,8 @@ plotImportance <- function(x, plot.type = c("bar", "heatmap"), imp.type = NULL, ) # create plot - g <- ggplot2::ggplot(imp.df, ggplot2::aes_string("type", "pred")) + - ggplot2::geom_raster(ggplot2::aes_string(fill = "value")) + + g <- ggplot2::ggplot(imp.df, ggplot2::aes(x = .data$type, y = .data$pred)) + + ggplot2::geom_raster(ggplot2::aes(fill = .data$value)) + ggplot2::theme(panel.background = ggplot2::element_blank()) g <- g + if(ranks) { ggplot2::scale_fill_gradient2( diff --git a/R/plotImpPreds.R b/R/plotImpPreds.R index a867b32..603b922 100755 --- a/R/plotImpPreds.R +++ b/R/plotImpPreds.R @@ -71,7 +71,7 @@ plotImpPreds <- function(x, df, class.col, imp.type = NULL, max.vars = 16, p <- df |> tidyr::pivot_longer(-.data$.class., names_to = "var") |> dplyr::mutate(var = factor(.data$var, levels = imp.vars)) |> - ggplot2::ggplot(ggplot2::aes_string(".class.", "value")) + + ggplot2::ggplot(ggplot2::aes(x = .data$.class., y = .data$value)) + ggplot2::geom_violin(alpha = violin.alpha) + ggplot2::geom_jitter(size = size, alpha = point.alpha, width = 0.25, height = 0) + ggplot2::facet_wrap(~ var, scales = "free_y") + diff --git a/R/plotInbag.R b/R/plotInbag.R index 8dc829f..3f39008 100755 --- a/R/plotInbag.R +++ b/R/plotInbag.R @@ -72,7 +72,7 @@ plotInbag <- function(x, bins = 10, replace = TRUE, sampsize = NULL, pct <- ((rf$ntree - rf$oob.times) / rf$ntree) * 100 bins <- max(bins, floor(length(pct) / 5)) p <- data.frame(pct = pct) |> - ggplot2::ggplot(ggplot2::aes_string("pct")) + + ggplot2::ggplot(ggplot2::aes(x = .data$pct)) + ggplot2::geom_histogram(bins = bins) + ggplot2::labs( x = "Percent of trees where sample was inbag", diff --git a/R/plotNull.R b/R/plotNull.R index 585938c..4c3eff4 100755 --- a/R/plotNull.R +++ b/R/plotNull.R @@ -75,7 +75,7 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, tidyr::gather("imp.type", "importance", -.data$predictor) |> dplyr::mutate(imp.type = factor(labels[imp.type], levels = labels)) - p <- ggplot2::ggplot(df, ggplot2::aes_string("importance")) + p <- ggplot2::ggplot(df, ggplot2::aes(x = .data$importance)) p <- if(plot.type == "hist") { p + ggplot2::geom_histogram() + ggplot2::ylab("Count") } else { @@ -85,7 +85,7 @@ plotNull <- function(x, preds = NULL, imp.type = NULL, scale = TRUE, ggplot2::xlab("Importance") + ggplot2::ggtitle(pr) + ggplot2::geom_vline( - ggplot2::aes_string(xintercept = "importance"), + ggplot2::aes(xintercept = .data$importance), color = "red", data = obs ) + ggplot2::facet_wrap(~ imp.type, scales = "free") diff --git a/R/plotPredictedProbs.R b/R/plotPredictedProbs.R index 89229a2..6a6c6af 100755 --- a/R/plotPredictedProbs.R +++ b/R/plotPredictedProbs.R @@ -34,7 +34,7 @@ plotPredictedProbs <- function(x, bins = 30, plot = TRUE) { tidyr::gather("pred.class", "prob", -.data$class, -.data$predicted) |> dplyr::filter(.data$predicted == .data$pred.class) |> dplyr::mutate(correct = .data$class == .data$predicted) |> - ggplot2::ggplot(ggplot2::aes_string("prob", fill = "class")) + + ggplot2::ggplot(ggplot2::aes(.data$prob, fill = .data$class)) + ggplot2::geom_histogram(bins = bins) + ggplot2::facet_wrap(~ predicted) + ggplot2::labs(x = "Assignment probability", y = "Frequency") + diff --git a/R/plotTrace.R b/R/plotTrace.R index 77a6ffc..cf5f2c5 100755 --- a/R/plotTrace.R +++ b/R/plotTrace.R @@ -35,8 +35,10 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { class = factor(.data$class, levels = colnames(df)), error = if(pct.correct) (1 - .data$error) * 100 else .data$error * 100 ) |> - ggplot2::ggplot(ggplot2::aes_string("trees", "error", color = "class")) + - ggplot2::geom_line(ggplot2::aes_string(linetype = "class")) + + ggplot2::ggplot( + ggplot2::aes(x = .data$trees, y = .data$error, color = .data$class) + ) + + ggplot2::geom_line(ggplot2::aes(linetype = .data$class)) + ggplot2::scale_color_manual(values = class.cols) + ggplot2::scale_linetype_manual(values = class.lines) + ggplot2::labs( @@ -46,7 +48,7 @@ plotTrace <- function(x, pct.correct = TRUE, plot = TRUE) { ggplot2::theme(legend.title = ggplot2::element_blank()) } else if(utils::hasName(rf, "mse")) { data.frame(trees = 1:length(rf$mse), error = rf$mse) |> - ggplot2::ggplot(ggplot2::aes_string("trees", "error")) + + ggplot2::ggplot(ggplot2::aes(x = .data$trees, y = .data$error)) + ggplot2::geom_line() + ggplot2::labs(x = "Trees", y = "Mean Squared Error") } else NULL From 3f32322da05661e1bbdb57cfaa6397ac5d7ed83f Mon Sep 17 00:00:00 2001 From: ericarcher Date: Mon, 6 Oct 2025 23:08:08 -0700 Subject: [PATCH 4/4] update to v.2.5.6 --- DESCRIPTION | 2 +- README.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 4053950..90ca4d0 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: Estimate significance of importance metrics metrics for each predictor variable and p-value of observed. Provides summary and visualization functions for 'randomForest' results. -Version: 2.5.5 +Version: 2.5.6 Authors@R: c( EA = person("Eric", "Archer", email = "eric.ivan.archer@gmail.com", role = c("aut", "cre"))) URL: https://github.com/SWFSC/rfPermute diff --git a/README.md b/README.md index b8873a7..41744b7 100755 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ devtools::install_github('EricArcher/rfPermute') ## Changelog +### version 2.5.6 (devel) + +* switched aes_string() for aes() in ggplot plots + ### version 2.5.5 (on CRAN) * move of package to SWFSC/rfPermute as main GitHub repository