Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c4c5cc9
Document required packages and prefix them
llrs-roche Feb 17, 2025
6c86226
Style R code output
llrs-roche Feb 17, 2025
1aba9c5
Address reviewer's comments
llrs-roche Feb 17, 2025
a053e94
Revert ubstitute call
llrs-roche Feb 17, 2025
bf6f6cb
Add library calls and prefix.
llrs-roche Feb 17, 2025
34232e3
Style code output
llrs-roche Feb 17, 2025
6741892
Adapt code output checks to recent changes
llrs-roche Feb 17, 2025
27611dd
Change single quotes to double quotes
llrs-roche Feb 17, 2025
a8c14fb
Fix typo
llrs-roche Feb 17, 2025
8239c69
[skip style] [skip vbump] Restyle files
github-actions[bot] Feb 17, 2025
df4b37d
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Feb 17, 2025
09ac901
Split lines to fix linter issues
llrs-roche Feb 18, 2025
3342c06
Fix NEWS message.
llrs-roche Feb 18, 2025
6a9ab33
Add version requirement for styler
llrs-roche Feb 18, 2025
e68c10a
Merge branch 'main' into 786_attached_packages@main
m7pr Feb 18, 2025
451cbc4
Apply suggestions from code review
llrs-roche Feb 18, 2025
4c58fe5
Address reviewer comments
llrs-roche Feb 19, 2025
aa3fc3c
Add more library calls
llrs-roche Feb 19, 2025
1e1fb29
Add ggpp and one ggplot2 call
llrs-roche Feb 19, 2025
4113eac
Add missing nolinter comment
llrs-roche Feb 19, 2025
2f14efb
Update docs
llrs-roche Feb 19, 2025
7d8c801
Only add ggpp when needed
llrs-roche Feb 19, 2025
3c9b4d3
Add more prefixes
llrs-roche Feb 19, 2025
ea51289
[skip style] [skip vbump] Restyle files
github-actions[bot] Feb 19, 2025
ff5c6e3
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Feb 19, 2025
c440364
revert to unprefixed call
llrs-roche Feb 19, 2025
72bc39a
prefix fortify in tm_a_regression
m7pr Feb 19, 2025
4a71d27
association plot typo
m7pr Feb 19, 2025
d6ea33a
make output code more readable in tm_g_association
m7pr Feb 19, 2025
c100e73
Update R/tm_g_association.R
llrs-roche Feb 19, 2025
23535a1
missing ggplot2:: prefix before expand_limits
m7pr Feb 19, 2025
41d3585
Merge branch '786_attached_packages@main' of https://github.com/insig…
m7pr Feb 19, 2025
867bcd6
Remove second library call for lattice
llrs-roche Feb 19, 2025
8fba660
Merge branch '786_attached_packages@main' of https://github.com/insig…
llrs-roche Feb 19, 2025
3481365
Remove styler dependency of code
llrs-roche Feb 19, 2025
2121668
Apply library change
llrs-roche Feb 19, 2025
317971d
Add missing parenthesis
llrs-roche Feb 19, 2025
22427b1
Remove utility function
llrs-roche Feb 19, 2025
3037961
[skip roxygen] [skip vbump] Roxygen Man Pages Auto Update
github-actions[bot] Feb 19, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ Imports:
sparkline (>= 2.0),
stats,
stringr (>= 1.4.1),
styler (>= 1.10.3),
teal.code (>= 0.6.0),
teal.data (>= 0.7.0),
teal.logger (>= 0.3.1),
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Removed `Show Warnings` modals from modules.
* Soft deprecated `datasets_selected` argument of modules in favor of `datanames`.
* Soft deprecated `show_metadata` argument of `tm_front_page()` in favor of `datanames`.
* Modules' Show R Code widgets include library calls and their code is styled with `styler` package (#847, #786).

### Enhancements

Expand Down
86 changes: 44 additions & 42 deletions R/tm_a_pca.R
Original file line number Diff line number Diff line change
Expand Up @@ -438,10 +438,10 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
selector_list = selector_list,
datasets = data
)

qenv <- teal.code::eval_code(data(), 'library("ggplot2")')
anl_merged_q <- reactive({
req(anl_merged_input())
data() %>%
qenv %>%
teal.code::eval_code(as.expression(anl_merged_input()$expr))
})

Expand Down Expand Up @@ -585,12 +585,12 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
theme = list(
legend.position = "right",
legend.spacing.y = quote(grid::unit(-5, "pt")),
legend.title = quote(element_text(vjust = 25)),
legend.title = quote(ggplot2::element_text(vjust = 25)),
axis.text.x = substitute(
element_text(angle = angle_value, hjust = hjust_value),
ggplot2::element_text(angle = angle_value, hjust = hjust_value),
list(angle_value = angle_value, hjust_value = hjust_value)
),
text = substitute(element_text(size = font_size), list(font_size = font_size))
text = substitute(ggplot2::element_text(size = font_size), list(font_size = font_size))
)
)

Expand All @@ -615,24 +615,24 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
)

cols <- c(getOption("ggplot2.discrete.colour"), c("lightblue", "darkred", "black"))[1:3]
elbow_plot <- ggplot(mapping = aes_string(x = "component", y = "value")) +
geom_bar(
aes(fill = "Single variance"),
elbow_plot <- ggplot2::ggplot(mapping = aes_string(x = "component", y = "value")) +
ggplot2::geom_bar(
ggplot2::aes(fill = "Single variance"),
data = dplyr::filter(elb_dat, metric == "Proportion of Variance"),
color = "black",
stat = "identity"
) +
geom_point(
aes(color = "Cumulative variance"),
ggplot2::geom_point(
ggplot2::aes(color = "Cumulative variance"),
data = dplyr::filter(elb_dat, metric == "Cumulative Proportion")
) +
geom_line(
aes(group = 1, color = "Cumulative variance"),
ggplot2::geom_line(
ggplot2::aes(group = 1, color = "Cumulative variance"),
data = dplyr::filter(elb_dat, metric == "Cumulative Proportion")
) +
labs +
scale_color_manual(values = c("Cumulative variance" = cols[2], "Single variance" = cols[3])) +
scale_fill_manual(values = c("Cumulative variance" = cols[2], "Single variance" = cols[1])) +
ggplot2::scale_color_manual(values = c("Cumulative variance" = cols[2], "Single variance" = cols[3])) +
ggplot2::scale_fill_manual(values = c("Cumulative variance" = cols[2], "Single variance" = cols[1])) +
ggthemes +
themes
},
Expand Down Expand Up @@ -660,9 +660,9 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl

dev_ggplot2_args <- teal.widgets::ggplot2_args(
theme = list(
text = substitute(element_text(size = font_size), list(font_size = font_size)),
text = substitute(ggplot2::element_text(size = font_size), list(font_size = font_size)),
axis.text.x = substitute(
element_text(angle = angle_val, hjust = hjust_val),
ggplot2::element_text(angle = angle_val, hjust = hjust_val),
list(angle_val = angle, hjust_val = hjust)
)
)
Expand Down Expand Up @@ -692,15 +692,15 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
y = sin(seq(0, 2 * pi, length.out = 100))
)

circle_plot <- ggplot(pca_rot) +
geom_point(aes_string(x = x_axis, y = y_axis)) +
geom_label(
aes_string(x = x_axis, y = y_axis, label = "label"),
circle_plot <- ggplot2::ggplot(pca_rot) +
ggplot2::geom_point(ggplot2::aes_string(x = x_axis, y = y_axis)) +
ggplot2::geom_label(
ggplot2::aes_string(x = x_axis, y = y_axis, label = "label"),
nudge_x = 0.1, nudge_y = 0.05,
fontface = "bold"
) +
geom_path(aes(x, y, group = 1), data = circle_data) +
geom_point(aes(x = x, y = y), data = data.frame(x = 0, y = 0), shape = "x", size = 5) +
ggplot2::geom_path(ggplot2::aes(x, y, group = 1), data = circle_data) +
ggplot2::geom_point(ggplot2::aes(x = x, y = y), data = data.frame(x = 0, y = 0), shape = "x", size = 5) +
labs +
ggthemes +
themes
Expand Down Expand Up @@ -794,7 +794,9 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
pca_plot_biplot_expr <- c(
pca_plot_biplot_expr,
substitute(
geom_point(aes_string(x = x_axis, y = y_axis), data = pca_rot, alpha = alpha, size = size),
ggplot2::geom_point(ggplot2::aes_string(x = x_axis, y = y_axis),
data = pca_rot, alpha = alpha, size = size
),
list(x_axis = input$x_axis, y_axis = input$y_axis, alpha = input$alpha, size = input$size)
)
)
Expand All @@ -805,7 +807,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
response <- ANL[[resp_col]]

aes_biplot <- substitute(
aes_string(x = x_axis, y = y_axis, color = "response"),
ggplot2::aes_string(x = x_axis, y = y_axis, color = "response"),
env = list(x_axis = x_axis, y_axis = y_axis)
)

Expand All @@ -826,15 +828,15 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
qenv,
quote(pca_rot$response <- as.factor(response))
)
quote(scale_color_brewer(palette = "Dark2"))
quote(ggplot2::scale_color_brewer(palette = "Dark2"))
} else if (inherits(response, "Date")) {
qenv <- teal.code::eval_code(
qenv,
quote(pca_rot$response <- numeric(response))
)

quote(
scale_color_gradient(
ggplot2::scale_color_gradient(
low = c(getOption("ggplot2.discrete.colour")[2], "darkred")[1],
high = c(getOption("ggplot2.discrete.colour"), "lightblue")[1],
labels = function(x) as.Date(x, origin = "1970-01-01")
Expand All @@ -845,7 +847,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
qenv,
quote(pca_rot$response <- response)
)
quote(scale_color_gradient(
quote(ggplot2::scale_color_gradient(
low = c(getOption("ggplot2.discrete.colour")[2], "darkred")[1],
high = c(getOption("ggplot2.discrete.colour"), "lightblue")[1]
))
Expand All @@ -854,7 +856,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
pca_plot_biplot_expr <- c(
pca_plot_biplot_expr,
substitute(
geom_point(aes_biplot, data = pca_rot, alpha = alpha, size = size),
ggplot2::geom_point(aes_biplot, data = pca_rot, alpha = alpha, size = size),
env = list(aes_biplot = aes_biplot, alpha = alpha, size = size)
),
scales_biplot
Expand All @@ -865,17 +867,17 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
pca_plot_biplot_expr <- c(
pca_plot_biplot_expr,
substitute(
geom_segment(
aes_string(x = "xstart", y = "ystart", xend = x_axis, yend = y_axis),
ggplot2::geom_segment(
ggplot2::aes_string(x = "xstart", y = "ystart", xend = x_axis, yend = y_axis),
data = rot_vars,
lineend = "round", linejoin = "round",
arrow = grid::arrow(length = grid::unit(0.5, "cm"))
),
env = list(x_axis = x_axis, y_axis = y_axis)
),
substitute(
geom_label(
aes_string(
ggplot2::geom_label(
ggplot2::aes_string(
x = x_axis,
y = y_axis,
label = "label"
Expand All @@ -886,7 +888,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
),
env = list(x_axis = x_axis, y_axis = y_axis)
),
quote(geom_point(aes(x = xstart, y = ystart), data = rot_vars, shape = "x", size = 5))
quote(ggplot2::geom_point(ggplot2::aes(x = xstart, y = ystart), data = rot_vars, shape = "x", size = 5))
)
}

Expand All @@ -896,9 +898,9 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
dev_ggplot2_args <- teal.widgets::ggplot2_args(
labs = dev_labs,
theme = list(
text = substitute(element_text(size = font_size), list(font_size = font_size)),
text = substitute(ggplot2::element_text(size = font_size), list(font_size = font_size)),
axis.text.x = substitute(
element_text(angle = angle_val, hjust = hjust_val),
ggplot2::element_text(angle = angle_val, hjust = hjust_val),
list(angle_val = angle, hjust_val = hjust)
)
)
Expand Down Expand Up @@ -946,9 +948,9 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl

dev_ggplot2_args <- teal.widgets::ggplot2_args(
theme = list(
text = substitute(element_text(size = font_size), list(font_size = font_size)),
text = substitute(ggplot2::element_text(size = font_size), list(font_size = font_size)),
axis.text.x = substitute(
element_text(angle = angle_val, hjust = hjust_val),
ggplot2::element_text(angle = angle_val, hjust = hjust_val),
list(angle_val = angle, hjust_val = hjust)
)
)
Expand All @@ -969,17 +971,17 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
list(
quote(ggplot(pca_rot)),
substitute(
geom_bar(
aes_string(x = "Variable", y = pc),
ggplot2::geom_bar(
ggplot2::aes_string(x = "Variable", y = pc),
stat = "identity",
color = "black",
fill = c(getOption("ggplot2.discrete.colour"), "lightblue")[1]
),
env = list(pc = pc)
),
substitute(
geom_text(
aes(
ggplot2::geom_text(
ggplot2::aes(
x = Variable,
y = pc_name,
label = round(pc_name, 3),
Expand Down Expand Up @@ -1123,7 +1125,7 @@ srv_a_pca <- function(id, data, reporter, filter_panel_api, dat, plot_height, pl
})

# Render R code.
source_code_r <- reactive(teal.code::get_code(req(decorated_output_q())))
source_code_r <- reactive(prepare_code(decorated_output_q()))

teal.widgets::verbatim_popup_srv(
id = "rcode",
Expand Down
Loading
Loading