Skip to content

Commit 0d60372

Browse files
authored
Remove ggmosaic from v0.5.0 (#935)
# Pull Request <!--- Replace `#nnn` with your issue link for reference. --> Fixes #932 Removes ggmosaic dependency and updates code as required by the new error message. <img width="625" height="267" alt="image" src="https://github.com/user-attachments/assets/c77ae1f0-17eb-446d-b925-aaa2018a8fda" /> Tested with released packages and also checked the app generated on the vignette (using-bivariate-plot) still works well on all shown cases. The user impact might be higher than initially thought as logical, character an ordered classes also use ggmosaic due to [L848](https://github.com/insightsengineering/teal.modules.general/pull/935/files#diff-a91c9cc30e476470275d1bd27bcd7e6d7440c5ca75daf9cb47dfc7062f3c9137R846). As an alternative we could use `plot(table())` which is not ggplot2 based but works with factors and characters. <details><summary>Reproducible example</summary> <p> ```r # general data example devtools::load_all("../teal.modules.general") library("teal.data") data <- within(teal_data(), { CO2 <- data.frame(CO2) }) init( data = data, modules = tm_g_bivariate( x = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = variable_choices(data[["CO2"]]), selected = "Type", fixed = FALSE ) ), y = data_extract_spec( dataname = "CO2", select = select_spec( label = "Select variable:", choices = variable_choices(data[["CO2"]]), selected = "Treatment", multiple = FALSE, fixed = FALSE ) ) ) ) |> runApp() ``` </p> </details>
1 parent 62aaefb commit 0d60372

File tree

9 files changed

+23
-33
lines changed

9 files changed

+23
-33
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ repos:
1515
- id: roxygenize
1616
name: Regenerate package documentation
1717
additional_dependencies:
18-
- ggmosaic
1918
- ggplot2
2019
- shiny
2120
- checkmate

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ URL: https://insightsengineering.github.io/teal.modules.general/,
2323
BugReports:
2424
https://github.com/insightsengineering/teal.modules.general/issues
2525
Depends:
26-
ggmosaic (>= 0.3.0),
2726
ggplot2 (>= 3.4.0),
2827
R (>= 4.1),
2928
shiny (>= 1.8.1),

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export(tm_missing_data)
2525
export(tm_outliers)
2626
export(tm_t_crosstable)
2727
export(tm_variable_browser)
28-
import(ggmosaic)
2928
import(ggplot2)
3029
import(shiny)
3130
import(teal)

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# teal.modules.general 0.5.1
2+
3+
- Removed ggmosaic package dependency to avoid being archived on CRAN (#932).
4+
15
# teal.modules.general 0.5.0
26

37
### Breaking changes

R/teal.modules.general.R

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#' (not necessarily for clinical trials data).
55
#'
66
#' @import ggplot2
7-
#' @import ggmosaic
87
#' @import shiny
98
#' @import teal
109
#' @import teal.transform
@@ -15,11 +14,5 @@
1514
#' @keywords internal
1615
"_PACKAGE"
1716

18-
# nolint start
19-
# Note ggmosaic (version <= 0.3.3) needs to be in DEPENDS as the following does not work if it is imported
20-
# df <- data.frame(x = c("A", "B", "C", "A"), y = c("Z", "Z", "W", "W"))
21-
# ggplot(df) + ggmosaic::geom_mosaic(aes(x = ggmosaic::product(x), fill = y))
22-
# nolint end
23-
2417
# Needed to avoid R CMD note on no visible binding
2518
utils::globalVariables("count")

R/tm_g_association.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ srv_tm_g_association <- function(id,
348348
)
349349

350350
qenv <- reactive(
351-
teal.code::eval_code(data(), 'library("ggplot2");library("dplyr");library("tern");library("ggmosaic")') # nolint quotes
351+
teal.code::eval_code(data(), 'library("ggplot2");library("dplyr");library("tern")') # nolint quotes
352352
)
353353
anl_merged_q <- reactive({
354354
req(anl_merged_input())

R/tm_g_bivariate.R

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,13 +968,7 @@ bivariate_ggplot_call <- function(x_class,
968968
)
969969
# Factor and character plots
970970
} else if (x_class == "factor" && y_class == "factor") {
971-
plot_call <- reduce_plot_call(
972-
plot_call,
973-
substitute(
974-
ggmosaic::geom_mosaic(aes(x = ggmosaic::product(xval), fill = yval), na.rm = TRUE),
975-
env = list(xval = x, yval = y)
976-
)
977-
)
971+
stop("Categorical variables 'x' and 'y' are currently not supported.")
978972
} else {
979973
stop("x y type combination not allowed")
980974
}

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ UI
88
datatables
99
facetting
1010
funder
11+
ggmosaic
1112
ggplot
1213
pre
1314
qq

tests/testthat/test_bivariate_ggplot_call.R

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,34 @@ testthat::test_that("bivariate_ggplot_call with numerics", {
1919
})
2020

2121
testthat::test_that("bivariate_ggplot_call with factor, char, logical", {
22-
testthat::expect_match(
22+
error_message <- "Categorical variables 'x' and 'y' are currently not supported."
23+
testthat::expect_error(
2324
bivariate_ggplot_call("factor", "factor") %>% deparse(width.cutoff = 300),
24-
"geom_mosaic"
25+
error_message
2526
)
26-
testthat::expect_match(
27+
testthat::expect_error(
2728
bivariate_ggplot_call("logical", "factor") %>% deparse(width.cutoff = 300),
28-
"geom_mosaic"
29-
)
30-
testthat::expect_match(
29+
error_message
30+
)
31+
testthat::expect_error(
3132
bivariate_ggplot_call("character", "factor") %>% deparse(width.cutoff = 300),
32-
"geom_mosaic"
33+
error_message
3334
)
34-
testthat::expect_match(
35+
testthat::expect_error(
3536
bivariate_ggplot_call("logical", "character") %>% deparse(width.cutoff = 300),
36-
"geom_mosaic"
37+
error_message
3738
)
38-
testthat::expect_match(
39+
testthat::expect_error(
3940
bivariate_ggplot_call("character", "logical") %>% deparse(width.cutoff = 300),
40-
"geom_mosaic"
41+
error_message
4142
)
42-
testthat::expect_match(
43+
testthat::expect_error(
4344
bivariate_ggplot_call("logical", "logical") %>% deparse(width.cutoff = 300),
44-
"geom_mosaic"
45+
error_message
4546
)
46-
testthat::expect_match(
47+
testthat::expect_error(
4748
bivariate_ggplot_call("character", "character") %>% deparse(width.cutoff = 300),
48-
"geom\\_mosaic"
49+
error_message
4950
)
5051
})
5152

0 commit comments

Comments
 (0)