Skip to content

Commit

Permalink
CRAN submission: see 0.8.4 (#341)
Browse files Browse the repository at this point in the history
* Update plot.n_factors.R

* delete unnecessary file

* effectsize vdiffr test

* add another vdiffr test

* Update NEWS.md

* also add merDeriv

* bump version

* get rid of ggrepel warnings

* size -> linewidth

* cran submission
  • Loading branch information
IndrajeetPatil authored Apr 29, 2024
1 parent 6a646ac commit 90be1b5
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 437 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: see
Title: Model Visualisation Toolbox for 'easystats' and 'ggplot2'
Version: 0.8.3.7
Version: 0.8.4
Authors@R:
c(person(given = "Daniel",
family = "Lüdecke",
Expand Down Expand Up @@ -91,6 +91,7 @@ Suggests:
logspline,
MASS,
mclust,
merDeriv,
mgcv,
metafor,
NbClust,
Expand Down Expand Up @@ -119,4 +120,3 @@ Config/Needs/website:
r-lib/pkgdown,
easystats/easystatstemplate
Config/rcmdcheck/ignore-inconsequential-notes: true
Remotes: easystats/performance
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# see 0.8.3.1
# see 0.8.4

## Minor Changes

* Fixes warnings generated from the `{ggplot2}` 3.5.0 release.

* Small adjustment to size of point geoms for `check_model()` plots.

* More arguments to change base font sizes and geom sizes are now passed to
Expand Down
4 changes: 3 additions & 1 deletion R/global_vars.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ utils::globalVariables(
"grp",
"Parameter",
"predictor",
"ROPE_Equivalence"
"ROPE_Equivalence",
"x_intercept",
"y_max"
)
)
6 changes: 4 additions & 2 deletions R/plot.check_homogeneity.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {
stringsAsFactors = FALSE
),
direction = "y",
segment.colour = NA
segment.colour = NA,
max.overlaps = Inf
)
} else {
geom_label(
Expand Down Expand Up @@ -96,7 +97,8 @@ plot.see_check_homogeneity <- function(x, data = NULL, ...) {
stringsAsFactors = FALSE
),
direction = "y",
segment.colour = NA
segment.colour = NA,
max.overlaps = Inf
)
} else {
geom_label(
Expand Down
18 changes: 10 additions & 8 deletions R/plot.n_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ data_plot.n_factors <- function(x, data = NULL, type = "bar", ...) {

dataplot <- rbind(s1, s2[!s2[[variable]] %in% s1[[variable]], ])

# Add Variance explained
if ("Variance_Explained" %in% names(attributes(x))) {
dataplot$Variance_Cumulative <- NULL # Remove column and re add
dataplot <- merge(
Expand All @@ -52,6 +51,7 @@ data_plot.n_factors <- function(x, data = NULL, type = "bar", ...) {
rownames(dataplot) <- NULL

# Labels and titles -----------------------------------------------------

n_max <- sum(dataplot$n_Methods)
axis_lab <- paste0("% of methods (out of ", n_max, ")")

Expand All @@ -67,7 +67,6 @@ data_plot.n_factors <- function(x, data = NULL, type = "bar", ...) {
ylab = axis_lab
)
}
# Title

attr(dataplot, "info")$title <- paste("How many", lab, "to retain")
attr(dataplot, "info")$subtitle <- paste0("Number of ", lab, " considered optimal by various algorithm")
Expand Down Expand Up @@ -137,21 +136,25 @@ plot.see_n_factors <- function(x,

# Base plot
if (type == "area") {
segment_data <- data.frame(x_intercept = x$x[which.max(x$y)], y_max = max(x$y, na.rm = TRUE))
p <- ggplot(x, aes(x = .data$x, y = .data$y)) +
geom_area(fill = flat_colors("grey")) +
geom_segment(
data = segment_data,
aes(
x = .data$x[which.max(.data$y)],
xend = .data$x[which.max(.data$y)],
x = x_intercept,
xend = x_intercept,
y = 0,
yend = max(.data$y)
yend = y_max
),
color = flat_colors("red")
) +
geom_point(aes(x = .data$x[which.max(.data$y)], y = max(.data$y)),
geom_point(
data = segment_data,
aes(x = x_intercept, y = y_max),
color = flat_colors("red")
) +
scale_x_continuous(breaks = 1:max(x$x)) +
scale_x_continuous(breaks = 1:max(x$x, na.rm = TRUE)) +
add_plot_attributes(x)
} else if (type == "line") {
p <- ggplot(x, aes(y = .data$x, x = .data$y, colour = .data$group)) +
Expand All @@ -172,7 +175,6 @@ plot.see_n_factors <- function(x,
scale_fill_manual(values = unname(flat_colors(c("grey", "red"))))
}

# Add variance explained
if ("Variance_Cumulative" %in% names(x)) {
x$Varex_scaled <- x$Variance_Cumulative * max(x$y)
p <- p +
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions tests/testthat/_snaps/plot.n_factors/area-graph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/testthat/test-check_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ test_that("`check_model()` works if convergence issues", {
test_that("`check_model()` works if convergence issues", {
skip_on_cran()
skip_if_not_installed("performance")
skip_if_not_installed("merDeriv")
data(mtcars)
m <- lm(mpg ~ wt + cyl + gear + disp, data = mtcars)
set.seed(123)
Expand Down
16 changes: 6 additions & 10 deletions tests/testthat/test-plot.effectsize_table.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
test_that("`plot.see_effectsize_table()` works", {
library(effectsize)
m <- aov(mpg ~ factor(am) * factor(cyl), data = mtcars)
result <- eta_squared(m)
expect_s3_class(plot(result), "gg")
})

test_that("`plot.see_equivalence_test()` works", {
library(effectsize)
m <- aov(mpg ~ factor(am) * factor(cyl), data = mtcars)
result <- eta_squared(m)
expect_s3_class(plot(result), "gg")
result <- effectsize::eta_squared(m)
set.seed(123)
vdiffr::expect_doppelganger(
title = "aov - eta_squared - dot plot",
fig = plot(result)
)
})
6 changes: 6 additions & 0 deletions tests/testthat/test-plot.n_factors.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ test_that("`plot.see_n_factors()` works", {
title = "line graph",
fig = plot(result, type = "line")
)

set.seed(123)
vdiffr::expect_doppelganger(
title = "area graph",
fig = plot(result, type = "area")
)
})
Loading

0 comments on commit 90be1b5

Please sign in to comment.