Skip to content

Commit 3801a26

Browse files
committed
fix: deprecated calls to aes_string in ggplot2 functions
1 parent 20c5d68 commit 3801a26

2 files changed

Lines changed: 81 additions & 83 deletions

File tree

R/explor_multi.R

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
if (getRversion() >= "2.15.1")
2-
utils::globalVariables(c("Type", "Contrib.x", "Contrib.y", "Cos2.x", "Cos2.y",
3-
"Level", "Variable", "Coord.x", "Coord.y", "Name",
4-
"P.value", "Class", "Cor", "Cor.x", "Cor.y", "Coord",
5-
"starts_with", "Contrib", "Cos2", "varname", "modname",
1+
if (getRversion() >= "2.15.1")
2+
utils::globalVariables(c("Type", "Contrib.x", "Contrib.y", "Cos2.x", "Cos2.y",
3+
"Level", "Variable", "Coord.x", "Coord.y", "Name",
4+
"P.value", "Class", "Cor", "Cor.x", "Cor.y", "Coord",
5+
"starts_with", "Contrib", "Cos2", "varname", "modname",
66
"V.test", "eta2", "con.tra", "name", "pos", "Axis", "Count"))
77

88

@@ -12,11 +12,11 @@ code_modal <- function(obj, plot_code, zoom_code) {
1212
code <- paste0("res <- explor::prepare_results(", obj, ")\n")
1313
code <- paste0(code, plot_code)
1414
code <- paste0(code, zoom_code, ")")
15-
16-
code <- formatR::tidy_source(text = code,
17-
width.cutoff = 75,
15+
16+
code <- formatR::tidy_source(text = code,
17+
width.cutoff = 75,
1818
output = FALSE)$text.tidy
19-
19+
2020
modalDialog(
2121
title = gettext("Export R code"),
2222
size = "l",
@@ -32,9 +32,9 @@ code_modal <- function(obj, plot_code, zoom_code) {
3232

3333
explor_multi_css <- function() {
3434
shiny::HTML("
35-
.well label,
36-
.well input,
37-
.well select,
35+
.well label,
36+
.well input,
37+
.well select,
3838
.well option,
3939
.well button,
4040
.well a,
@@ -56,18 +56,18 @@ explor_multi_css <- function() {
5656
.well #var_sup_choice .checkbox {
5757
margin-top: 0px;
5858
margin-bottom: 0px;
59-
}
60-
.dataTable th,
59+
}
60+
.dataTable th,
6161
.dataTable td {
6262
font-size: 11px !important;
63-
padding: 3px 5px !important;
63+
padding: 3px 5px !important;
6464
}
6565
.dataTable th { padding-right: 18px !important }
6666
.dataTables_wrapper {
6767
max-width: 850px;
6868
margin-bottom: 2em;
6969
}
70-
.dataTables_info, .dataTables_length,
70+
.dataTables_info, .dataTables_length,
7171
.dataTables_filter, .dataTables_paginate {
7272
font-size: 11px !important;
7373
}
@@ -94,7 +94,7 @@ explor_multi_css <- function() {
9494
explor_multi_lasso_callback <- function() {
9595
"function(sel) {
9696
var selected = sel.data().map(function(d) {return d.key_var});
97-
var values = selected.join('<br />');
97+
var values = selected.join('<br />');
9898
var r_code = 'c(\"' + selected.join('\", \"') + '\")';
9999
var out = '<h4>IDs</h4><p><pre>'+values+'</pre></p>';
100100
out += '<h4>R vector</h4>';
@@ -113,7 +113,7 @@ explor_multi_zoom_callback <- function(type = "var") {
113113

114114
explor_multi_sidebar_footer <- function(type = "var") {
115115
list(
116-
checkboxInput(paste0(type, "_transitions"),
116+
checkboxInput(paste0(type, "_transitions"),
117117
HTML(gettext("Animations")),
118118
value = TRUE),
119119
if (type != "bi") {
@@ -127,7 +127,7 @@ explor_multi_sidebar_footer <- function(type = "var") {
127127
tags$p(tags$a(id = paste0("explor-", type, "-svg-export"),
128128
class = "btn btn-default",
129129
HTML(paste(icon("file-image"), gettext("Export as SVG"))))))
130-
130+
131131
}
132132

133133

@@ -181,7 +181,7 @@ explor_multi_ind_dataUI <- function(id, settings, axes) {
181181
fluidRow(
182182
column(2,
183183
wellPanel(
184-
selectInput(ns("inddim"),
184+
selectInput(ns("inddim"),
185185
gettext("Dimension"),
186186
choices = axes, selected = "Axis 1"))),
187187
column(10,
@@ -225,11 +225,11 @@ explor_multi_ind_data <- function(input, output, session, res, settings) {
225225

226226
## Axes inputs
227227
explor_multi_axes_input <- function(res, type) {
228-
x_input <- selectInput(paste0(type, "_x"),
229-
gettext("X axis"),
228+
x_input <- selectInput(paste0(type, "_x"),
229+
gettext("X axis"),
230230
choices = res$axes, selected = "1")
231-
y_input <- selectInput(paste0(type, "_y"),
232-
gettext("Y axis"),
231+
y_input <- selectInput(paste0(type, "_y"),
232+
gettext("Y axis"),
233233
choices = res$axes, selected = "2")
234234
return(list(x_input, y_input))
235235
}
@@ -252,7 +252,7 @@ explor_multi_var_size_input <- function(settings) {
252252
}
253253
names(var_size_choices) <- names
254254
var_size_input <- if (length(var_size_choices) > 1) {
255-
selectInput("var_size",
255+
selectInput("var_size",
256256
gettext("Points size :"),
257257
choices = var_size_choices,
258258
selected = "None")
@@ -291,7 +291,7 @@ explor_multi_var_col_input <- function(settings) {
291291
names(choices)[choices == "Variable"] <- gettext("Variable name")
292292
names(choices)[choices == "Type"] <- gettext("Variable type")
293293
names(choices)[choices == "Position"] <- gettext("Variable position")
294-
294+
295295
selectInput("var_col", gettext("Points color :"),
296296
choices = choices, selected = selected)
297297
}
@@ -320,7 +320,7 @@ explor_multi_var_symbol_input <- function(settings) {
320320
names(choices)[choices == "Position"] <- gettext("Variable position")
321321

322322
selectInput("var_symbol", gettext("Points symbol :"),
323-
choices = choices, selected = selected)
323+
choices = choices, selected = selected)
324324
}
325325

326326
## Individual color input
@@ -331,7 +331,7 @@ explor_multi_ind_col_input <- function(settings, res) {
331331
ind_col_choices <- c(ind_col_choices, names(res$quali_data))
332332
ind_col_choices <- setdiff(ind_col_choices, "Name")
333333

334-
selectInput("ind_col",
334+
selectInput("ind_col",
335335
gettext("Points color :"),
336336
choices = ind_col_choices,
337337
selected = "None")
@@ -351,7 +351,7 @@ explor_multi_ind_opacity_input <- function(settings) {
351351
}
352352
names(ind_opacity_choices) <- names
353353
ind_opacity_input <- if (length(ind_opacity_choices) > 1) {
354-
selectInput("ind_opacity_var",
354+
selectInput("ind_opacity_var",
355355
gettext("Points opacity :"),
356356
choices = ind_opacity_choices,
357357
selected = "Fixed")
@@ -372,16 +372,16 @@ explor_multi_auto_labels_input <- function(data, type) {
372372
## Supplementary variables choice input
373373
explor_multi_var_sup_choice_input <-function(data, settings) {
374374
if (settings$type == "CA") {
375-
vnames <- data %>%
376-
filter(Type == "Supplementary variable") %>%
377-
select(.data$Level) %>%
378-
distinct() %>%
375+
vnames <- data %>%
376+
filter(Type == "Supplementary variable") %>%
377+
select(.data$Level) %>%
378+
distinct() %>%
379379
pull(.data$Level)
380380
} else {
381-
vnames <- data %>%
382-
filter(Type == "Supplementary") %>%
383-
select(.data$Variable) %>%
384-
distinct() %>%
381+
vnames <- data %>%
382+
filter(Type == "Supplementary") %>%
383+
select(.data$Variable) %>%
384+
distinct() %>%
385385
pull(.data$Variable)
386386
}
387387
checkboxGroupInput(
@@ -421,7 +421,7 @@ explor_multi_bi_symbol_input <- function(settings) {
421421
names(choices)[choices == "Nature"] <- gettext("Variable level / Individual")
422422

423423
selectInput("bi_symbol", gettext("Points symbol :"),
424-
choices = choices, selected = selected)
424+
choices = choices, selected = selected)
425425
}
426426

427427
## Biplot color input
@@ -438,7 +438,7 @@ explor_multi_bi_col_input <- function(settings) {
438438
names(choices)[choices == "Variable"] <- gettext("Variable name")
439439
names(choices)[choices == "Type"] <- gettext("Active / Supplementary")
440440
names(choices)[choices == "Nature"] <- gettext("Variable level / Individual")
441-
441+
442442
selectInput("bi_col", gettext("Points color :"),
443443
choices = choices, selected = selected)
444444
}
@@ -457,7 +457,7 @@ explor_multi_bi_ind_opacity_input <- function(settings) {
457457
}
458458
names(bi_opacity_choices) <- names
459459
bi_opacity_input <- if (length(bi_opacity_choices) > 1) {
460-
selectInput("bi_opacity_var",
460+
selectInput("bi_opacity_var",
461461
gettext("Points opacity :"),
462462
choices = bi_opacity_choices,
463463
selected = "Fixed")
@@ -484,18 +484,18 @@ explor_multi_var_dataUI <- function(id, settings, axes) {
484484
fluidRow(
485485
column(2,
486486
wellPanel(
487-
selectInput(ns("vardim"),
487+
selectInput(ns("vardim"),
488488
gettext("Dimension"),
489489
choices = axes, selected = "1"),
490490
if (settings$type == "CA") {
491-
selectInput(ns("var_tab_hide"),
491+
selectInput(ns("var_tab_hide"),
492492
gettext("Hide :"),
493493
choices = explor_multi_hide_choices(),
494494
selected = "None")
495495
}
496496
)),
497497
column(10,
498-
h4(if(settings$type == "CA") gettext("Active levels")
498+
h4(if(settings$type == "CA") gettext("Active levels")
499499
else gettext("Active variables")),
500500
DT::DTOutput(ns("vartable")),
501501
if (settings$has_sup_vars || (settings$type == "CA" && settings$has_sup_levels)) {
@@ -532,7 +532,7 @@ explor_multi_var_data <- function(input, output, session, res, settings) {
532532
autoWidth = FALSE, searching = TRUE)
533533
## Active variables
534534
varTable <- reactive({
535-
tmp <- res()$vars %>%
535+
tmp <- res()$vars %>%
536536
filter(Type == "Active", Axis == input$vardim) %>%
537537
select(all_of(settings()$var_columns))
538538
## CA data hide option
@@ -549,7 +549,7 @@ explor_multi_var_data <- function(input, output, session, res, settings) {
549549

550550
## Supplementary variables
551551
varTableSup <- reactive({
552-
tmp <- res()$vars %>%
552+
tmp <- res()$vars %>%
553553
filter(grepl("Supplementary", Type), Axis == input$vardim) %>%
554554
mutate(Level = ifelse(Class == "Quantitative", "-", Level))
555555
## CA data hide option
@@ -563,14 +563,14 @@ explor_multi_var_data <- function(input, output, session, res, settings) {
563563
tmp <- tmp %>% select(all_of(settings()$varsup_columns))
564564
data.frame(tmp)
565565
})
566-
566+
567567
output$vartablesup <- DT::renderDT(
568568
explor_multi_table(varTableSup(), table_options, "Coord"))
569569

570570
## PCA qualitative supplementary variable
571571
varTableQualiSup <- reactive({
572572
if (settings()$type == "PCA" && settings()$has_quali_sup_vars) {
573-
tmp <- res()$vars %>%
573+
tmp <- res()$vars %>%
574574
filter(Type == "Supplementary", Class == "Qualitative",
575575
Axis == input$vardim) %>%
576576
select(all_of(settings()$varsup_quali_columns))
@@ -616,9 +616,9 @@ explor_multi_eigenUI <- function(id, eig) {
616616
ns <- NS(id)
617617
fluidRow(
618618
column(2,
619-
wellPanel(numericInput(ns("eig_nb"),
620-
gettext("Dimensions to plot"),
621-
min = 2, max = max(eig$dim), value = max(eig$dim),
619+
wellPanel(numericInput(ns("eig_nb"),
620+
gettext("Dimensions to plot"),
621+
min = 2, max = max(eig$dim), value = max(eig$dim),
622622
step = 1))),
623623
column(5,
624624
h4(gettext("Eigenvalues histogram")),
@@ -636,7 +636,7 @@ explor_multi_eigen <- function(input, output, session, eig) {
636636
tmp <- eig()[1:nb(),]
637637
tmp$dim <- factor(tmp$dim)
638638
ggplot(data = tmp) +
639-
geom_bar(aes_string(x = "dim", y = "percent"), stat = "identity") +
639+
geom_bar(aes(x = .data[["dim"]], y = .data[["percent"]]), stat = "identity") +
640640
scale_x_discrete(gettext("Axis")) +
641641
scale_y_continuous(gettext("Percentage of inertia"))
642642
})
@@ -650,5 +650,3 @@ explor_multi_eigen <- function(input, output, session, eig) {
650650
dt %>% DT::formatRound(c("%", "Cum. %"), digits = 1)
651651
})
652652
}
653-
654-

0 commit comments

Comments
 (0)