From 692847a8298c4b0c2c485f4b379c02498bbc5748 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 3 Dec 2023 13:55:40 +0100 Subject: [PATCH] lintr --- R/plot.parameters_brms_meta.R | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/R/plot.parameters_brms_meta.R b/R/plot.parameters_brms_meta.R index f97e20d44..b16f052b6 100644 --- a/R/plot.parameters_brms_meta.R +++ b/R/plot.parameters_brms_meta.R @@ -19,45 +19,45 @@ data_plot.parameters_brms_meta <- function(x, data = NULL, normalize_height = TR } # summary - summary <- x[, 1:6] - summary$Parameter <- attributes(x)$cleaned_parameters - colnames(summary)[2] <- "Estimate" - summary$Estimate_CI <- sprintf( + datasummary <- x[, 1:6] + datasummary$Parameter <- attributes(x)$cleaned_parameters + colnames(datasummary)[2] <- "Estimate" + datasummary$Estimate_CI <- sprintf( "%.2f %s", - summary$Estimate, + datasummary$Estimate, insight::format_ci( - summary$CI_low, - summary$CI_high, + datasummary$CI_low, + datasummary$CI_high, ci = NULL, digits = 2, zap_small = TRUE ) ) - summary$Parameter <- factor(summary$Parameter, levels = rev(unique(summary$Parameter))) - colnames(summary)[match("Parameter", colnames(summary))] <- "Study" + datasummary$Parameter <- factor(datasummary$Parameter, levels = rev(unique(datasummary$Parameter))) + colnames(datasummary)[match("Parameter", colnames(datasummary))] <- "Study" - summary$x <- NA_real_ - summary$y <- NA_real_ - summary$Color <- "Study" - summary$Color[summary$Study == "Overall"] <- "Overall" + datasummary$x <- NA_real_ + datasummary$y <- NA_real_ + datasummary$Color <- "Study" + datasummary$Color[datasummary$Study == "Overall"] <- "Overall" if ("ROPE_low" %in% names(x) && "ROPE_high" %in% names(x)) { - attr(summary, "rope") <- c(x$ROPE_low[1], x$ROPE_high[1]) + attr(datasummary, "rope") <- c(x$ROPE_low[1], x$ROPE_high[1]) } dataplot <- dataplot[dataplot$Study != "tau", ] - summary <- summary[summary$Study != "tau", ] + datasummary <- datasummary[datasummary$Study != "tau", ] dataplot$Study <- droplevels(dataplot$Study) - summary$Study <- droplevels(summary$Study) + datasummary$Study <- droplevels(datasummary$Study) dataplot$Group <- "Study" dataplot$Group[dataplot$Study == "Overall"] <- "Overall" dataplot$Color <- "Study" dataplot$Color[dataplot$Study == "Overall"] <- "Overall" - attr(dataplot, "summary") <- summary + attr(dataplot, "summary") <- datasummary attr(dataplot, "info") <- list( xlab = "Standardized Mean Difference", ylab = NULL, @@ -164,7 +164,7 @@ plot.see_parameters_brms_meta <- function(x, x <- data_plot(x, data = model, normalize_height = normalize_height, ...) } - summary <- attributes(x)$summary + datasummary <- attributes(x)$summary rope <- attributes(summary)$rope p <- ggplot2::ggplot(x, mapping = ggplot2::aes(x = .data$x, y = .data$Study, height = .data$y)) @@ -192,7 +192,7 @@ plot.see_parameters_brms_meta <- function(x, alpha = posteriors_alpha ) + ggplot2::geom_errorbarh( - data = summary, + data = datasummary, mapping = ggplot2::aes( xmin = .data$CI_low, xmax = .data$CI_high, @@ -201,7 +201,7 @@ plot.see_parameters_brms_meta <- function(x, linewidth = size_line ) + ggplot2::geom_point( - data = summary, + data = datasummary, mapping = ggplot2::aes(x = .data$Estimate, color = .data$Color), size = size_point, fill = "white", @@ -229,7 +229,7 @@ plot.see_parameters_brms_meta <- function(x, p <- p + ggplot2::geom_text( - data = summary, + data = datasummary, mapping = ggplot2::aes(label = .data$Estimate_CI, x = Inf), hjust = "inward", size = size_text