Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
^docs$
^pkgdown$
^README.html$
^extras$
^extras$
^vignettes/articles$
2 changes: 1 addition & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, develop]
branches: [main, master]
pull_request:
release:
types: [published]
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ README.html
SRS.*
extras/SRS.qmd
extras/SRS.docx
docs
inst/doc
10 changes: 8 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: studyGenerics
Type: Package
Title: A centralised repository of tested and frequently used methods for OMOP-CDM studies
Version: 0.0.0.9000
Version: 0.0.0.9002
Authors@R: c(
person(
"Cesar", "Barboza",
Expand Down Expand Up @@ -37,7 +37,13 @@ Imports:
fs,
usethis
Config/roxygen2/version: 8.0.0
Suggests:
Suggests:
gert,
gh,
knitr,
rmarkdown,
testthat (>= 3.0.0)
Config/testthat/edition: 3
URL: https://mi-erasmusmc.github.io/studyGenerics/
VignetteBuilder: knitr
Config/Needs/website: rmarkdown
5 changes: 5 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
export(arrangeCdmNames)
export(assertCdmNames)
export(createResultsDir)
export(developCheckout)
export(getPkgZips)
export(insertStructure)
export(issueOpen)
export(pullRequest)
export(setLoggers)
export(unZipStudyFiles)
export(zipStudyFiles)
Expand All @@ -16,6 +19,8 @@ importFrom(checkmate,assertCharacter)
importFrom(checkmate,assertDirectoryExists)
importFrom(checkmate,assertFileExists)
importFrom(checkmate,assertLogical)
importFrom(checkmate,assertTRUE)
importFrom(checkmate,checkClass)
importFrom(cli,cli_abort)
importFrom(cli,cli_alert_danger)
importFrom(cli,cli_alert_info)
Expand Down
14 changes: 13 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# studyGenerics 0.0.9002

* New article about `insertStructure()`

* New `updateColumnValues()`

* 'macOS solves' article

# studyGenerics 0.0.9001

* Version control functions: `issueOpen()`, `pullRequest`, `developCheckout`

# studyGenerics 0.0.9000

* readme and initial functions.
* readme and initial functions.
30 changes: 30 additions & 0 deletions R/getPkgZips.R
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,33 @@ mockLock <- function() {
return(lockfile)
}

suppPackages <- function() {
list(
Packages = list(
devtools = list(
Package = "devtools",
Version = "2.5.2"
), # 2.5.2 exists in multiple releases, should pick from the newest (R v4.6)
dplyr = list(
Package = "dplyr",
Version = "0.6"
), # there is no 0.6 in any of the releases, should get v1.2.1 as alternate from R v4.4
tidyrr = list(
Package = "tidyr",
Version = "1.3.2"
), # tidyrr does not exist
RPostgres = list(
Package = "RPostgres",
Version = NULL
), # no version provided, should get v1.4.10 as alternate from R v4.4
renv = list(
Package = "renv",
Version = "1.0.7"
), # renv already exists in lockfile, if override_lock = TRUE, should get v1.0.7 from R v4.2
xfun = list(
Package = "xfun",
Version = NULL
)
)
) # xfun already exists in lockfile, if override_lock = TRUE, should get v0.57 from R v4.4
}
27 changes: 27 additions & 0 deletions R/updateColumnValues.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' Update values in a summarised result
#'
#' @description
#' Updates the character values of specific column(s) in a summarised result object
#' (e.g., changing cohort names to a more polished version for Shiny app labels)
#' according to a given name mapping.
#'
#' @param summarised_result The summarised result with values to update.
#' @param names_map A named vector containing the mapping between old and new names.
#' @param variable The column name(s) containing the values to be updated in the
#' summarised result object.
#'
#' @returns The summarised result itself with updated values.
#'
updateColumnValues <- function(
summarised_result,
names_map,
variable
) {

summarised_result[[variable]] <- dplyr::recode(
summarised_result[[variable]],
!!!names_map
)

return(summarised_result)
}
38 changes: 30 additions & 8 deletions R/versionControl.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@
#'
#' @returns A message with the link of the PR
#' @importFrom checkmate assertCharacter assertLogical assertTRUE checkClass
#' @importFrom gh gh gh_tree_remote gh_token_exists
#' @importFrom gert git_branch_create git_branch
#' @export
#' @examples
issueOpen <- function(
title,
body,
newBranch = FALSE
) {
if (!requireNamespace("gh", quietly = TRUE)) {
stop(
"Package \"gh\" must be installed to use this function.",
call. = FALSE
)
}
if (!requireNamespace("gert", quietly = TRUE)) {
stop(
"Package \"gert\" must be installed to use this function.",
call. = FALSE
)
}
checkmate::assertCharacter(
title,
len = 1,
Expand Down Expand Up @@ -85,15 +94,24 @@ issueOpen <- function(
#'
#' @returns A message with the link of the issue
#' @importFrom checkmate assertCharacter assertLogical assertTRUE checkClass
#' @importFrom gh gh gh_tree_remote gh_token_exists
#' @importFrom gert git_branch_create git_branch
#' @export
#' @examples
pullRequest <- function(
title,
body,
base = "develop"
) {
if (!requireNamespace("gh", quietly = TRUE)) {
stop(
"Package \"gh\" must be installed to use this function.",
call. = FALSE
)
}
if (!requireNamespace("gert", quietly = TRUE)) {
stop(
"Package \"gert\" must be installed to use this function.",
call. = FALSE
)
}
checkmate::assertCharacter(
title,
len = 1,
Expand Down Expand Up @@ -136,10 +154,14 @@ pullRequest <- function(
#' and pull latest changes
#'
#' @returns Git log messages after checking out and pulling 'develop'
#' @importFrom gert git_branch_exists git_branch_checkout git_pull
#' @export
#' @examples
developCheckout <- function() {
if (!requireNamespace("gert", quietly = TRUE)) {
stop(
"Package \"gert\" must be installed to use this function.",
call. = FALSE
)
}
branch <- "develop"
if (gert::git_branch_exists(branch)) {
gert::git_branch_checkout(
Expand Down
16 changes: 16 additions & 0 deletions man/developCheckout.Rd

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

2 changes: 1 addition & 1 deletion man/insertDocs.Rd

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

24 changes: 24 additions & 0 deletions man/issueOpen.Rd

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

23 changes: 23 additions & 0 deletions man/pullRequest.Rd

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

24 changes: 24 additions & 0 deletions man/updateColumnValues.Rd

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

2 changes: 1 addition & 1 deletion studyGenerics.Rproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version: 1.0
sVersion: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test-cdmNames.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("assertCdmNames works", {
# Assert a group of acryonims
# Assert a group of acronyms
labels <- c(
"BCR",
"IQVIA LPD Belgium",
Expand All @@ -9,9 +9,9 @@ test_that("assertCdmNames works", {
)
assertCdmNames(labels = labels) |>
expect_invisible()
# Error acronim do not match
# Error acronym do not match
labels <- c(
"BCRX", # Mispelled acronym
"BCRX", # Misspelled acronym
"IQVIA LPD Belgium",
"NLHR@UiO:PERINATAL",
"IQVIA US - AmbEMR",
Expand All @@ -22,7 +22,7 @@ test_that("assertCdmNames works", {
})

test_that("assertCdmNames against expected acronyms", {
# Assert a group of acryonims
# Assert a group of acronyms
labels <- c(
"BCR",
"IQVIA LPD Belgium",
Expand All @@ -42,7 +42,7 @@ test_that("assertCdmNames against expected acronyms", {
expect_error()
# Incorrect acronym
labels <- c(
"BCRX", # Mispelled acronym
"BCRX", # Misspelled acronym
"IQVIA LPD Belgium",
"NLHR@UiO:PERINATAL",
"IQVIA US - AmbEMR",
Expand Down Expand Up @@ -78,9 +78,9 @@ test_that("arrangeCdmNames returns required acronyms in order", {
"IQVIA US - AmbEMR",
"IQVIA US - PMTX+"
))
# Error acronim do not match
# Error acronym do not match
labels <- c(
"BCRX", # Mispelled acronym
"BCRX", # Misspelled acronym
"IQVIA LPD Belgium",
"NLHR@UiO:PERINATAL",
"IQVIA US - AmbEMR",
Expand Down
Loading
Loading