Skip to content

Commit

Permalink
Fix some R CMD CHK build error and warnings (#743)
Browse files Browse the repository at this point in the history
* Add {future} and {future.callr} as required packages

* Use `.data$`

* Document all parameters

* Simplify the code and avoid using `runif`

* [check-spelling] Update metadata

Update for https://github.com/Public-Health-Scotland/source-linkage-files/actions/runs/5573642848/attempts/1
Accepted in #743 (comment)

Signed-off-by: check-spelling-bot <[email protected]>

---------

Signed-off-by: check-spelling-bot <[email protected]>
  • Loading branch information
Moohan authored Jul 17, 2023
1 parent 8e1bcc9 commit 3f86f89
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ itle
iwalk
jaccard
jan
jennifer
jul
keydate
keyring
Expand All @@ -104,6 +105,8 @@ ltc
ltcs
lubridate
magrittr
Mcbride
mcmahon
MMMYY
monthflag
mpat
Expand Down Expand Up @@ -200,5 +203,6 @@ xintercept
xlsx
yearstay
YYYYQX
zihao
zsav
zstd
2 changes: 2 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Imports:
dtplyr (>= 1.3.0),
fs (>= 1.6.1),
fst (>= 0.9.8),
future (>= 1.33.0),
future.callr (>= 0.8.1),
glue (>= 1.6.2),
haven (>= 2.5.2),
hms (>= 1.1.0),
Expand Down
4 changes: 2 additions & 2 deletions R/produce_test_comparison.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ produce_test_comparison <- function(old_data, new_data, recid = FALSE) {
dplyr::mutate(
difference = round(.data$value_new - .data$value_old, digits = 2L),
pct_change = .data$difference / .data$value_old,
issue = !dplyr::between(pct_change, -0.05, 0.05)
issue = !dplyr::between(.data$pct_change, -0.05, 0.05)
)
} else {
dplyr::full_join(old_data,
Expand All @@ -34,7 +34,7 @@ produce_test_comparison <- function(old_data, new_data, recid = FALSE) {
dplyr::mutate(
difference = round(.data$value_new - .data$value_old, digits = 2L),
pct_change = .data$difference / .data$value_old,
issue = !dplyr::between(pct_change, -0.05, 0.05)
issue = !dplyr::between(.data$pct_change, -0.05, 0.05)
)
}
}
1 change: 1 addition & 0 deletions R/run_episode_file.R
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ create_cohort_lookups <- function(data, year, update = latest_update()) {
#' Join cohort lookups
#'
#' @inheritParams store_ep_file_vars
#' @inheritParams get_demographic_cohorts_path
#'
#' @return The data including the Demographic and Service Use lookups.
join_cohort_lookups <- function(data, year, update = latest_update()) {
Expand Down
4 changes: 2 additions & 2 deletions R/write_tests_xlsx.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ write_tests_xlsx <- function(comparison_data, sheet_name, year = NULL) {
while (fs::file_exists(path = in_use_path) && seconds < max_wait) {
# While the tests are in use (wait a random number of seconds from 1 to 30)
cli::cli_progress_update()
wait <- round(runif(1, 1, 15))
wait <- sample(x = 3:15, size = 1)

Sys.sleep(wait)
seconds <- seconds + wait
Expand All @@ -56,7 +56,7 @@ write_tests_xlsx <- function(comparison_data, sheet_name, year = NULL) {
}

# Final check to maybe avoid corrupting the workbook
Sys.sleep(round(runif(1, 1, 3)))
Sys.sleep(sample(x = 1:3, size = 1))
if (!fs::file_exists(path = in_use_path)) {
fs::file_create(path = in_use_path)
} else {
Expand Down
2 changes: 2 additions & 0 deletions man/join_cohort_lookups.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3f86f89

Please sign in to comment.