Skip to content

Commit e80e752

Browse files
committed
lintr
1 parent bdee66e commit e80e752

4 files changed

Lines changed: 93 additions & 80 deletions

File tree

R/mod_bsafe.R

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,16 @@ bsafe_server <- function(
163163
id,
164164
dataset) {
165165
module <- function(input, output, session) {
166-
shiny::addResourcePath("www", system.file("www", package = "dv.modules.bsafe"))
166+
shiny::addResourcePath(
167+
"www",
168+
system.file("www", package = "dv.modules.bsafe")
169+
)
167170

168171
# global variables --------------------------------------------------------
169172

170-
ns <- session[["ns"]]
173+
ns <- session[["ns"]] # nolintr
171174

172-
ae_summary_data <- NULL
175+
ae_summary_data <- NULL # nolintr
173176

174177
# data input/checks/transformation ----------------------------------------
175178
receive_data <- shinymeta::metaReactive2(
@@ -246,7 +249,6 @@ bsafe_server <- function(
246249
# Data table preparation
247250
sel_analysis <- mod_select_analysis_server("sel_analysis", data_preparation)
248251
selected_data <- sel_analysis[["data"]] # TODO: Careful with reactive overlap once poc is ready
249-
seed <- sel_analysis[["seed"]]
250252

251253
map_prior <- mod_map_prior_server(
252254
"map_prior",
@@ -310,7 +312,9 @@ bsafe_server <- function(
310312

311313
# nolint start
312314

313-
tmpfolder <- tempfile(tmpdir = system.file("www", package = "dv.modules.bsafe"))
315+
tmpfolder <- tempfile(
316+
tmpdir = system.file("www", package = "dv.modules.bsafe")
317+
)
314318
dir.create(tmpfolder)
315319

316320
download_results <- mod_simulation_server(
@@ -321,7 +325,8 @@ bsafe_server <- function(
321325

322326
shiny::onStop(function() {
323327
unlink(
324-
system.file(paste0("/www", strsplit(tmpfolder, "www")[[1]][2]),
328+
system.file(
329+
paste0("/www", strsplit(tmpfolder, "www")[[1]][2]),
325330
package = "dv.modules.bsafe",
326331
mustWork = TRUE
327332
),
@@ -331,7 +336,6 @@ bsafe_server <- function(
331336

332337
# nolint end
333338

334-
335339
# return ----
336340

337341
to_report <- shiny::reactive({

R/mod_data_preparation.R

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,6 @@ mod_data_preparation_server <- function(id, data) {
6666

6767
shiny::setBookmarkExclude(names = BSAFE_ID$BUT_ADD_ARM)
6868

69-
70-
71-
get_names <- function(name, length) {
72-
helper <- paste0(name, 1)
73-
for (i in 2:length) {
74-
helper <- c(helper, paste0(name, i))
75-
}
76-
helper
77-
}
78-
7969
# Initial menus
8070

8171
shiny::observe({

inst/template_ae_summary_table.Rmd

Lines changed: 71 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -73,58 +73,39 @@ print(params$ae_summary_log)
7373
for (g in groups) {
7474
# pasting together the chosen arms of ARM A aka treatment arm and separating them by comma as well as removing the last comma
7575
ARMS_ARM_A <- substr(
76-
paste0(cb_list_trt[[paste0("grp", g)]],
77-
", ",
78-
collapse = ""
79-
),
76+
paste0(cb_list_trt[[paste0("grp", g)]], ", ", collapse = ""),
8077
STRING_START,
81-
nchar(paste0(cb_list_trt[[paste0("grp", g)]],
82-
", ",
83-
collapse = ""
84-
)) - COMMA_PLUS_ONE_SPACE
78+
nchar(paste0(cb_list_trt[[paste0("grp", g)]], ", ", collapse = "")) -
79+
COMMA_PLUS_ONE_SPACE
8580
)
8681
# pasting together the chosen arms of ARM B aka control arm and separating them by comma as well as removing the last comma
8782
ARMS_ARM_B <- substr(
88-
paste0(cb_list_ctr[[paste0("grp", g)]],
89-
", ",
90-
collapse = ""
91-
),
83+
paste0(cb_list_ctr[[paste0("grp", g)]], ", ", collapse = ""),
9284
STRING_START,
93-
nchar(paste0(cb_list_ctr[[paste0("grp", g)]],
94-
", ",
95-
collapse = ""
96-
)) - COMMA_PLUS_ONE_SPACE
85+
nchar(paste0(cb_list_ctr[[paste0("grp", g)]], ", ", collapse = "")) -
86+
COMMA_PLUS_ONE_SPACE
9787
)
9888
# list element as data frame for kableExtra
9989
list_comparisons[[g]] <- as.data.frame(
10090
cbind(
10191
# pasting together the IDs of ARM A aka treatment arm and separating them by comma as well as removing the last comma
10292
substr(
103-
paste0(ID_trt_list[[paste0("grp", g)]],
104-
", ",
105-
collapse = ""
106-
),
93+
paste0(ID_trt_list[[paste0("grp", g)]], ", ", collapse = ""),
10794
STRING_START,
108-
nchar(paste0(ID_trt_list[[paste0("grp", g)]],
109-
", ",
110-
collapse = ""
111-
)) - COMMA_PLUS_ONE_SPACE
95+
nchar(paste0(ID_trt_list[[paste0("grp", g)]], ", ", collapse = "")) -
96+
COMMA_PLUS_ONE_SPACE
11297
),
11398
# same with ARM B or control arm
11499
substr(
115-
paste0(ID_ctr_list[[paste0("grp", g)]],
116-
", ",
117-
collapse = ""
118-
),
100+
paste0(ID_ctr_list[[paste0("grp", g)]], ", ", collapse = ""),
119101
STRING_START,
120-
nchar(paste0(ID_ctr_list[[paste0("grp", g)]],
121-
", ",
122-
collapse = ""
123-
)) - COMMA_PLUS_ONE_SPACE
102+
nchar(paste0(ID_ctr_list[[paste0("grp", g)]], ", ", collapse = "")) -
103+
COMMA_PLUS_ONE_SPACE
124104
)
125105
)
126106
)
127-
table_comparisons <- kableExtra::kable(list_comparisons[[g]],
107+
table_comparisons <- kableExtra::kable(
108+
list_comparisons[[g]],
128109
format = "latex",
129110
# to enable a stable width of the table
130111
booktabs = TRUE,
@@ -145,20 +126,31 @@ for (g in groups) {
145126
ARMS_ARM_B
146127
)
147128
148-
149-
list_table_1_1[[g]] <- cbind(as.data.frame(array_inci[, , 1, g, drop = FALSE]), as.data.frame(array_inci[, , 2, g, drop = FALSE]))
150-
# list_table_1_1[[g]] <- list_table_1_1[[g]] |> na.omit()
151-
list_table_1_1[[g]][, c(3, 10)] <- round(list_table_1_1[[g]][, c(3, 10)] * 100, 1)
152-
list_table_1_1[[g]][, c(3, 10)] <- round(list_table_1_1[[g]][, c(3, 10)] * 100, 1)
153-
table_display_1 <- kableExtra::kable(list_table_1_1[[g]],
129+
list_table_1_1[[g]] <- cbind(
130+
as.data.frame(array_inci[, , 1, g, drop = FALSE]),
131+
as.data.frame(array_inci[, , 2, g, drop = FALSE])
132+
)
133+
# nolintr list_table_1_1[[g]] <- list_table_1_1[[g]] |> na.omit()
134+
list_table_1_1[[g]][, c(3, 10)] <- round(
135+
list_table_1_1[[g]][, c(3, 10)] * 100,
136+
1
137+
)
138+
list_table_1_1[[g]][, c(3, 10)] <- round(
139+
list_table_1_1[[g]][, c(3, 10)] * 100,
140+
1
141+
)
142+
table_display_1 <- kableExtra::kable(
143+
list_table_1_1[[g]],
154144
format = "latex",
155-
booktabs = TRUE, digits = 3,
145+
booktabs = TRUE,
146+
digits = 3,
156147
longtable = TRUE,
157148
col.names = rep(c("r", "n", "%", "mean", "median", "CRI L", "CRI U"), 2),
158149
caption = table_caption_1
159150
) |>
160151
kableExtra::kable_styling(font_size = 8) |>
161-
kableExtra::add_header_above( # adding extra separation layer of both Arms above the column names. They have to be equal to the names of the array/list
152+
kableExtra::add_header_above(
153+
# adding extra separation layer of both Arms above the column names. They have to be equal to the names of the array/list
162154
c(
163155
"Arm A" = 7,
164156
"Arm B" = 7
@@ -182,14 +174,22 @@ for (g in groups) {
182174
" vs. Arm B: ",
183175
ARMS_ARM_B
184176
)
185-
list_table_1_2[[g]] <- cbind(as.data.frame(array_inci_comp[, , 1, g, drop = FALSE]), as.data.frame(array_inci_comp[, , 2, g, drop = FALSE]))
186-
# list_table_1_2[[g]] <- as.data.frame(cbind(array_inci_comp[, , 1, g], array_inci_comp[, , 2, g]))
187-
# list_table_1_2[[g]] <- list_table_1_2[[g]] |> na.omit()
188-
table_display_2 <- kableExtra::kable(list_table_1_2[[g]][, -6],
177+
list_table_1_2[[g]] <- cbind(
178+
as.data.frame(array_inci_comp[, , 1, g, drop = FALSE]),
179+
as.data.frame(array_inci_comp[, , 2, g, drop = FALSE])
180+
)
181+
# nolintr list_table_1_2[[g]] <- as.data.frame(cbind(array_inci_comp[, , 1, g], array_inci_comp[, , 2, g]))
182+
# nolintr list_table_1_2[[g]] <- list_table_1_2[[g]] |> na.omit()
183+
table_display_2 <- kableExtra::kable(
184+
list_table_1_2[[g]][, -6],
189185
format = "latex",
190-
booktabs = TRUE, digits = 3,
186+
booktabs = TRUE,
187+
digits = 3,
191188
longtable = TRUE,
192-
col.names = c(rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2), "A>B%"),
189+
col.names = c(
190+
rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2),
191+
"A>B%"
192+
),
193193
caption = table_caption_2
194194
) |>
195195
kableExtra::kable_styling(font_size = 8) |>
@@ -222,12 +222,17 @@ for (g in groups) {
222222
" vs. Arm B: ",
223223
ARMS_ARM_B
224224
)
225-
# list_table_2_1[[g]] <- as.data.frame(cbind(array_er[, , 1, g], array_er[, , 2, g]))
226-
list_table_2_1[[g]] <- cbind(as.data.frame(array_er[, , 1, g, drop = FALSE]), as.data.frame(array_er[, , 2, g, drop = FALSE]))
227-
# list_table_2_1[[g]] <- list_table_2_1[[g]] |> na.omit()
228-
table_display_3 <- kableExtra::kable(list_table_2_1[[g]],
225+
# nolintr list_table_2_1[[g]] <- as.data.frame(cbind(array_er[, , 1, g], array_er[, , 2, g]))
226+
list_table_2_1[[g]] <- cbind(
227+
as.data.frame(array_er[, , 1, g, drop = FALSE]),
228+
as.data.frame(array_er[, , 2, g, drop = FALSE])
229+
)
230+
# nolintr list_table_2_1[[g]] <- list_table_2_1[[g]] |> na.omit()
231+
table_display_3 <- kableExtra::kable(
232+
list_table_2_1[[g]],
229233
format = "latex",
230-
booktabs = TRUE, digits = 3,
234+
booktabs = TRUE,
235+
digits = 3,
231236
longtable = TRUE,
232237
col.names = rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2),
233238
caption = table_caption_3
@@ -260,17 +265,25 @@ for (g in groups) {
260265
" vs. Arm B: ",
261266
ARMS_ARM_B
262267
)
263-
list_table_2_2[[g]] <- cbind(as.data.frame(array_er_comp[, , 1, g, drop = FALSE]), as.data.frame(array_er_comp[, , 2, g, drop = FALSE]))
264-
# list_table_2_2[[g]] <- as.data.frame(cbind(array_er_comp[, , 1, g], array_er_comp[, , 2, g]))
265-
# list_table_2_2[[g]] <- list_table_2_2[[g]] |> na.omit()
268+
list_table_2_2[[g]] <- cbind(
269+
as.data.frame(array_er_comp[, , 1, g, drop = FALSE]),
270+
as.data.frame(array_er_comp[, , 2, g, drop = FALSE])
271+
)
272+
# nolintr list_table_2_2[[g]] <- as.data.frame(cbind(array_er_comp[, , 1, g], array_er_comp[, , 2, g]))
273+
# nolintr list_table_2_2[[g]] <- list_table_2_2[[g]] |> na.omit()
266274
if (length(list_table_2_2[[g]]) == 0) {
267275
print("Analysis is not applicable!")
268276
} else {
269-
table_display_4 <- kableExtra::kable(list_table_2_2[[g]][, -6],
277+
table_display_4 <- kableExtra::kable(
278+
list_table_2_2[[g]][, -6],
270279
format = "latex",
271-
booktabs = TRUE, digits = 3,
280+
booktabs = TRUE,
281+
digits = 3,
272282
longtable = TRUE,
273-
col.names = c(rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2), "A>B%"),
283+
col.names = c(
284+
rep(c("Naive", "mean", "median", "CRI L", "CRI U"), 2),
285+
"A>B%"
286+
),
274287
caption = table_caption_4
275288
) |>
276289
kableExtra::kable_styling(font_size = 8) |>

tests/testthat/test-map_prior.R

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ local({
148148
purrr::walk(button_id, function(id) {
149149
app$click(id)
150150
app$wait_for_idle()
151-
expect_error(class = "shiny.silent.error", shiny::isolate(app$get_values()[["export"]][["r"]][["map_mcmc"]]()))
151+
expect_error(
152+
class = "shiny.silent.error",
153+
shiny::isolate(app$get_values()[["export"]][["r"]][["map_mcmc"]]())
154+
)
152155
app$click(tns("submit"))
153156
app$wait_for_idle()
154157
})
@@ -157,12 +160,15 @@ local({
157160

158161
app$set_inputs(!!tns(BSAFE_ID$SEL_HIST_BORROW) := "Large")
159162
app$wait_for_idle()
160-
expect_error(class = "shiny.silent.error", shiny::isolate(app$get_values()[["export"]][["r"]][["map_mcmc"]]()))
163+
expect_error(
164+
class = "shiny.silent.error",
165+
shiny::isolate(app$get_values()[["export"]][["r"]][["map_mcmc"]]())
166+
)
161167

162168
# sel_tau
163169
# Only one value in sel tau is available
164-
# app$set_inputs(!!tns(BSAFE_ID$SEL_TAU) := "Half-normal")
165-
# app$wait_for_idle()
166-
# expect_error(class = "shiny.silent.error", shiny::isolate(app$get_values()[["export"]][["r"]][["map_mcmc"]]()))
170+
# nolintr app$set_inputs(!!tns(BSAFE_ID$SEL_TAU) := "Half-normal")
171+
# nolintr app$wait_for_idle()
172+
# nolintr expect_error(class = "shiny.silent.error", shiny::isolate(app$get_values()[["export"]][["r"]][["map_mcmc"]]()))
167173
})
168174
})

0 commit comments

Comments
 (0)