From 8e42e6e7f1781bb917cd92b392de084b2b97591b Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 4 Jun 2024 14:50:14 +0200 Subject: [PATCH] lintr --- R/format.R | 12 ++++++------ R/remove_empty.R | 2 +- R/reshape_ci.R | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/R/format.R b/R/format.R index a73fbdbcf..84374fa13 100644 --- a/R/format.R +++ b/R/format.R @@ -20,16 +20,16 @@ format.parameters_distribution <- function(x, digits = 2, format = NULL, ci_widt ci_lvl <- attributes(x)$ci centrality_ci <- attributes(x)$first_centrality - if (!is.null(centrality_ci)) { - ci_suffix <- paste0(" (", centrality_ci, ")") - } else { + if (is.null(centrality_ci)) { ci_suffix <- "" + } else { + ci_suffix <- paste0(" (", centrality_ci, ")") } - if (!is.null(ci_lvl)) { - colnames(x)[which(colnames(x) == "CI_low")] <- sprintf("%i%% CI%s", round(100 * ci_lvl), ci_suffix) - } else { + if (is.null(ci_lvl)) { colnames(x)[which(colnames(x) == "CI_low")] <- sprintf("CI%s", ci_suffix) + } else { + colnames(x)[which(colnames(x) == "CI_low")] <- sprintf("%i%% CI%s", round(100 * ci_lvl), ci_suffix) } } diff --git a/R/remove_empty.R b/R/remove_empty.R index c7fd75423..4d5afb530 100644 --- a/R/remove_empty.R +++ b/R/remove_empty.R @@ -77,7 +77,7 @@ empty_rows <- function(x) { if ((!is.matrix(x) && !is.data.frame(x)) || nrow(x) < 2) { vector("numeric") } else { - which(rowSums((is.na(x) | x == "")) == ncol(x)) + which(rowSums((is.na(x) | x == "")) == ncol(x)) # nolint } } diff --git a/R/reshape_ci.R b/R/reshape_ci.R index ef3976ec9..245567cfb 100644 --- a/R/reshape_ci.R +++ b/R/reshape_ci.R @@ -42,11 +42,11 @@ reshape_ci <- function(x, ci_type = "CI") { # Reshape if (length(unique(x$CI)) > 1) { - if (!"Parameter" %in% names(x)) { + if ("Parameter" %in% names(x)) { + remove_parameter <- FALSE + } else { x$Parameter <- NA remove_parameter <- TRUE - } else { - remove_parameter <- FALSE } x <- stats::reshape( @@ -70,11 +70,11 @@ reshape_ci <- function(x, ci_type = "CI") { # Wide to long -------------- } else { - if (!"Parameter" %in% names(x)) { + if ("Parameter" %in% names(x)) { + remove_parameter <- FALSE + } else { x$Parameter <- seq_len(nrow(x)) remove_parameter <- TRUE - } else { - remove_parameter <- FALSE } lows <- grepl(paste0(ci_low, "_*"), names(x))