Skip to content

Commit a0ea710

Browse files
committed
style(lint): linting all + re-running rmd
1 parent 6aa9345 commit a0ea710

16 files changed

+76
-77
lines changed

R/choose_replications.R

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,6 @@ confidence_interval_method <- function(replications, desired_precision,
459459
param <- parameters(number_of_runs = replications)
460460
results <- runner(param, use_future_seeding = FALSE)[["run_results"]]
461461

462-
# If mean of metric is less than 1, multiply by 100
463-
# if (mean(results[[metric]]) < 1L) {
464-
# results[[paste0("adj_", metric)]] <- results[[metric]] * 100L
465-
# metric <- paste0("adj_", metric)
466-
# }
467-
468462
# Initialise list to store the results
469463
cumulative_list <- list()
470464

@@ -476,7 +470,7 @@ confidence_interval_method <- function(replications, desired_precision,
476470
subset_data <- results[[metric]][1L:i]
477471

478472
# Get latest data point
479-
last_data_point <- tail(subset_data, n=1)
473+
last_data_point <- tail(subset_data, n = 1L)
480474

481475
# Calculate mean
482476
mean_value <- mean(subset_data)
@@ -530,28 +524,31 @@ confidence_interval_method <- function(replications, desired_precision,
530524
warning("Running ", replications, " replications did not reach ",
531525
"desired precision (", desired_precision, ").", call. = FALSE)
532526
}
533-
return(cumulative)
527+
cumulative
534528
}
535529

536530

537-
#' Generate a plot of metric and confidence intervals with increasing simulation replications
531+
#' Generate a plot of metric and confidence intervals with increasing
532+
#' simulation replications
538533
#'
539-
#' @param conf_ints A dataframe containing confidence interval statistics, including cumulative mean, upper/lower bounds, and deviations. As returned by ReplicationTabuliser summary_table() method.
534+
#' @param conf_ints A dataframe containing confidence interval statistics,
535+
#' including cumulative mean, upper/lower bounds, and deviations. As returned
536+
#' by ReplicationTabuliser summary_table() method.
540537
#' @param yaxis_title Label for y axis.
541538
#' @param file_path Path and filename to save the plot to.
542-
#' @param min_rep The number of replications required to meet the desired precision.
539+
#' @param min_rep The number of replications required to meet the desired
540+
#' precision.
543541

544-
plot_replication_ci = function(
545-
conf_ints, yaxis_title, file_path = NULL, min_rep = NULL
546-
)
547-
{
542+
plot_replication_ci <- function(
543+
conf_ints, yaxis_title, file_path = NULL, min_rep = NULL
544+
) {
548545
# Plot the cumulative mean and confidence interval
549546
p <- ggplot2::ggplot(conf_ints,
550547
ggplot2::aes(x = .data[["replications"]],
551548
y = .data[["cumulative_mean"]])) +
552549
ggplot2::geom_line() +
553550
ggplot2::geom_ribbon(
554-
ggplot2::aes(ymin = lower_ci, ymax = upper_ci),
551+
ggplot2::aes(ymin = .data[["lower_ci"]], ymax = .data[["upper_ci"]]),
555552
alpha = 0.2
556553
)
557554

outputs/cores1.png

12.8 KB
Loading

outputs/cores2.png

2.48 KB
Loading

rmarkdown/analysis.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ run_results %>%
7474
group_by(key) %>%
7575
reframe(mean = mean(value, na.rm = TRUE),
7676
std_dev = stats::sd(value, na.rm = TRUE),
77-
ci_lower = stats::t.test(value)[["conf.int"]][[1]],
78-
ci_upper = stats::t.test(value)[["conf.int"]][[2]])
77+
ci_lower = stats::t.test(value)[["conf.int"]][[1L]],
78+
ci_upper = stats::t.test(value)[["conf.int"]][[2L]])
7979
```
8080

8181
## View spread of results across replication

rmarkdown/analysis.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Analysis
22
================
33
Amy Heather
4-
2025-03-12
4+
2025-03-17
55

66
- [Set up](#set-up)
77
- [Default run](#default-run)
@@ -105,8 +105,8 @@ run_results %>%
105105
group_by(key) %>%
106106
reframe(mean = mean(value, na.rm = TRUE),
107107
std_dev = stats::sd(value, na.rm = TRUE),
108-
ci_lower = stats::t.test(value)[["conf.int"]][[1]],
109-
ci_upper = stats::t.test(value)[["conf.int"]][[2]])
108+
ci_lower = stats::t.test(value)[["conf.int"]][[1L]],
109+
ci_upper = stats::t.test(value)[["conf.int"]][[2L]])
110110
```
111111

112112
## # A tibble: 5 × 5
@@ -391,7 +391,7 @@ print(table_latex)
391391
```
392392

393393
## % latex table generated in R 4.4.1 by xtable 1.8-4 package
394-
## % Wed Mar 12 16:11:33 2025
394+
## % Mon Mar 17 15:49:56 2025
395395
## \begin{table}[ht]
396396
## \centering
397397
## \begin{tabular}{rrllll}
@@ -647,7 +647,7 @@ print(sensitivity_table_latex)
647647
```
648648

649649
## % latex table generated in R 4.4.1 by xtable 1.8-4 package
650-
## % Wed Mar 12 16:12:14 2025
650+
## % Mon Mar 17 15:50:37 2025
651651
## \begin{table}[ht]
652652
## \centering
653653
## \begin{tabular}{rrl}
@@ -694,18 +694,18 @@ tail(nan_experiment[["arrivals"]])
694694
```
695695

696696
## name start_time end_time activity_time resource replication
697-
## 16136 patient131 64.07388 NA NA nurse 100
698-
## 16137 patient63 32.62716 NA NA nurse 100
697+
## 16136 patient78 38.80769 NA NA nurse 100
698+
## 16137 patient74 37.63360 NA NA nurse 100
699699
## 16138 patient76 38.71731 NA NA nurse 100
700-
## 16139 patient99 49.99761 NA NA nurse 100
701-
## 16140 patient69 35.83208 NA NA nurse 100
700+
## 16139 patient134 64.35663 NA NA nurse 100
701+
## 16140 patient73 36.35539 NA NA nurse 100
702702
## 16141 patient77 38.74436 NA NA nurse 100
703703
## serve_start serve_length wait_time wait_time_unseen
704-
## 16136 NA NA NA 15.92612
705-
## 16137 NA NA NA 47.37284
704+
## 16136 NA NA NA 41.19231
705+
## 16137 NA NA NA 42.36640
706706
## 16138 NA NA NA 41.28269
707-
## 16139 NA NA NA 30.00239
708-
## 16140 NA NA NA 44.16792
707+
## 16139 NA NA NA 15.64337
708+
## 16140 NA NA NA 43.64461
709709
## 16141 NA NA NA 41.25564
710710

711711
``` r
@@ -764,4 +764,4 @@ seconds <- as.integer(runtime %% 60L)
764764
cat(sprintf("Notebook run time: %dm %ds", minutes, seconds))
765765
```
766766

767-
## Notebook run time: 2m 5s
767+
## Notebook run time: 2m 19s

rmarkdown/choosing_cores.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Choosing cores
22
================
33
Amy Heather
4-
2025-03-11
4+
2025-03-17
55

66
- [Set up](#set-up)
77
- [Run time with varying number of CPU
@@ -32,18 +32,17 @@ devtools::install()
3232
```
3333

3434
##
35-
## ── R CMD build ──────────────────────────────────────────────────────────────────────────────────
35+
## ── R CMD build ───────────────────────────────────────────────────────────────────────────────
3636
## checking for file ‘/home/amy/Documents/stars/rap_template_r_des/DESCRIPTION’ ... ✔ checking for file ‘/home/amy/Documents/stars/rap_template_r_des/DESCRIPTION’
3737
## ─ preparing ‘simulation’:
3838
## checking DESCRIPTION meta-information ... ✔ checking DESCRIPTION meta-information
3939
## ─ checking for LF line-endings in source and make files and shell scripts
4040
## ─ checking for empty or unneeded directories
41-
## Removed empty directory ‘simulation/tests/testthat/_snaps’
4241
## Omitted ‘LazyData’ from DESCRIPTION
4342
## ─ building ‘simulation_0.1.0.tar.gz’
4443
##
4544
## Running /opt/R/4.4.1/lib/R/bin/R CMD INSTALL \
46-
## /tmp/RtmptoyQW1/simulation_0.1.0.tar.gz --install-tests
45+
## /tmp/RtmpJhKlRH/simulation_0.1.0.tar.gz --install-tests
4746
## * installing to library ‘/home/amy/.cache/R/renv/library/rap_template_r_des-cd7d6844/linux-ubuntu-noble/R-4.4/x86_64-pc-linux-gnu’
4847
## * installing *source* package ‘simulation’ ...
4948
## ** using staged installation
@@ -217,4 +216,4 @@ seconds <- as.integer(runtime %% 60L)
217216
cat(sprintf("Notebook run time: %dm %ds", minutes, seconds))
218217
```
219218

220-
## Notebook run time: 2m 13s
219+
## Notebook run time: 2m 22s

rmarkdown/choosing_replications.Rmd

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ plot_replication_ci(
175175
conf_ints = filter(alg$summary_table, metric == "mean_serve_time_nurse"),
176176
yaxis_title = "Mean time with nurse",
177177
file_path = path,
178-
min_rep = alg$nreps[["mean_serve_time_nurse"]])
178+
min_rep = alg$nreps[["mean_serve_time_nurse"]]
179+
)
179180
include_graphics(path)
180181
```
181182

rmarkdown/choosing_replications.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,8 @@ plot_replication_ci(
384384
conf_ints = filter(alg$summary_table, metric == "mean_serve_time_nurse"),
385385
yaxis_title = "Mean time with nurse",
386386
file_path = path,
387-
min_rep = alg$nreps[["mean_serve_time_nurse"]])
387+
min_rep = alg$nreps[["mean_serve_time_nurse"]]
388+
)
388389
include_graphics(path)
389390
```
390391

@@ -416,4 +417,4 @@ seconds <- as.integer(runtime %% 60L)
416417
cat(sprintf("Notebook run time: %dm %ds", minutes, seconds))
417418
```
418419

419-
## Notebook run time: 3m 1s
420+
## Notebook run time: 1m 37s

rmarkdown/choosing_warmup.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Choosing warm-up length
22
================
33
Amy Heather
4-
2025-03-12
4+
2025-03-17
55

66
- [Set-up](#set-up)
77
- [Determining appropriate warm-up

rmarkdown/generate_exp_results.Rmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ results <- runner(param)
6161
6262
# Arrivals
6363
head(results[["arrivals"]])
64-
write.csv(results[["arrivals"]] %>% arrange(replication, start_time),
64+
write.csv(arrange(results[["arrivals"]], replication, start_time),
6565
file.path(testdata_dir, "base_arrivals.csv"),
6666
row.names = FALSE)
6767
@@ -147,7 +147,7 @@ param <- parameters(
147147
148148
# Run the confidence_interval_method()
149149
rep_results <- confidence_interval_method(
150-
replications = 15,
150+
replications = 15L,
151151
desired_precision = 0.05,
152152
metric = "mean_serve_time_nurse"
153153
)

0 commit comments

Comments
 (0)