Skip to content

Commit

Permalink
Merge branch 'rc_datawizard_0.11.0' of https://github.com/easystats/d…
Browse files Browse the repository at this point in the history
…atawizard into rc_datawizard_0.11.0
  • Loading branch information
etiennebacher committed Jun 4, 2024
2 parents 7de5bf7 + 8e42e6e commit 416fd42
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/remove_empty.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
12 changes: 6 additions & 6 deletions R/reshape_ci.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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))
Expand Down

0 comments on commit 416fd42

Please sign in to comment.