From 58519ba4e335a745725ea212e7dbc43100b7fe3a Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 14:55:07 +0100 Subject: [PATCH 01/21] Create R package --- .Rbuildignore | 4 + .Rprofile | 1 + DESCRIPTION | 11 + NAMESPACE | 1 + R/hello.R | 18 + man/hello.Rd | 12 + omop-bundles.Rproj | 20 + renv.lock | 23 + renv/.gitignore | 7 + renv/activate.R | 1220 ++++++++++++++++++++++++++++++++++++++++++++ renv/settings.json | 19 + 11 files changed, 1336 insertions(+) create mode 100644 .Rbuildignore create mode 100644 .Rprofile create mode 100644 DESCRIPTION create mode 100644 NAMESPACE create mode 100644 R/hello.R create mode 100644 man/hello.Rd create mode 100644 omop-bundles.Rproj create mode 100644 renv.lock create mode 100644 renv/.gitignore create mode 100644 renv/activate.R create mode 100644 renv/settings.json diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..d821302 --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,4 @@ +^renv$ +^renv\.lock$ +^.*\.Rproj$ +^\.Rproj\.user$ diff --git a/.Rprofile b/.Rprofile new file mode 100644 index 0000000..81b960f --- /dev/null +++ b/.Rprofile @@ -0,0 +1 @@ +source("renv/activate.R") diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..99ccac4 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,11 @@ +Package: omopbundles +Type: Package +Title: What the Package Does (Title Case) +Version: 0.1.0 +Author: Who wrote it +Maintainer: The package maintainer +Description: More about what it does (maybe more than one line) + Use four spaces when indenting paragraphs within the Description. +License: What license is it under? +Encoding: UTF-8 +LazyData: true diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..d75f824 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1 @@ +exportPattern("^[[:alpha:]]+") diff --git a/R/hello.R b/R/hello.R new file mode 100644 index 0000000..3d348f2 --- /dev/null +++ b/R/hello.R @@ -0,0 +1,18 @@ +# Hello, world! +# +# This is an example function named 'hello' +# which prints 'Hello, world!'. +# +# You can learn more about package authoring with RStudio at: +# +# http://r-pkgs.had.co.nz/ +# +# Some useful keyboard shortcuts for package authoring: +# +# Install Package: 'Cmd + Shift + B' +# Check Package: 'Cmd + Shift + E' +# Test Package: 'Cmd + Shift + T' + +hello <- function() { + print("Hello, world!") +} diff --git a/man/hello.Rd b/man/hello.Rd new file mode 100644 index 0000000..0fa7c4b --- /dev/null +++ b/man/hello.Rd @@ -0,0 +1,12 @@ +\name{hello} +\alias{hello} +\title{Hello, World!} +\usage{ +hello() +} +\description{ +Prints 'Hello, world!'. +} +\examples{ +hello() +} diff --git a/omop-bundles.Rproj b/omop-bundles.Rproj new file mode 100644 index 0000000..f6cd4b6 --- /dev/null +++ b/omop-bundles.Rproj @@ -0,0 +1,20 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: XeLaTeX + +AutoAppendNewline: Yes +StripTrailingWhitespace: Yes + +BuildType: Package +PackageUseDevtools: Yes +PackageInstallArgs: --no-multiarch --with-keep.source diff --git a/renv.lock b/renv.lock new file mode 100644 index 0000000..c993a8c --- /dev/null +++ b/renv.lock @@ -0,0 +1,23 @@ +{ + "R": { + "Version": "4.4.1", + "Repositories": [ + { + "Name": "CRAN", + "URL": "https://packagemanager.posit.co/cran/latest" + } + ] + }, + "Packages": { + "renv": { + "Package": "renv", + "Version": "1.0.7", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "utils" + ], + "Hash": "397b7b2a265bc5a7a06852524dabae20" + } + } +} diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000..0ec0cbb --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,7 @@ +library/ +local/ +cellar/ +lock/ +python/ +sandbox/ +staging/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 0000000..d13f993 --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,1220 @@ + +local({ + + # the requested version of renv + version <- "1.0.7" + attr(version, "sha") <- NULL + + # the project directory + project <- Sys.getenv("RENV_PROJECT") + if (!nzchar(project)) + project <- getwd() + + # use start-up diagnostics if enabled + diagnostics <- Sys.getenv("RENV_STARTUP_DIAGNOSTICS", unset = "FALSE") + if (diagnostics) { + start <- Sys.time() + profile <- tempfile("renv-startup-", fileext = ".Rprof") + utils::Rprof(profile) + on.exit({ + utils::Rprof(NULL) + elapsed <- signif(difftime(Sys.time(), start, units = "auto"), digits = 2L) + writeLines(sprintf("- renv took %s to run the autoloader.", format(elapsed))) + writeLines(sprintf("- Profile: %s", profile)) + print(utils::summaryRprof(profile)) + }, add = TRUE) + } + + # figure out whether the autoloader is enabled + enabled <- local({ + + # first, check config option + override <- getOption("renv.config.autoloader.enabled") + if (!is.null(override)) + return(override) + + # if we're being run in a context where R_LIBS is already set, + # don't load -- presumably we're being run as a sub-process and + # the parent process has already set up library paths for us + rcmd <- Sys.getenv("R_CMD", unset = NA) + rlibs <- Sys.getenv("R_LIBS", unset = NA) + if (!is.na(rlibs) && !is.na(rcmd)) + return(FALSE) + + # next, check environment variables + # TODO: prefer using the configuration one in the future + envvars <- c( + "RENV_CONFIG_AUTOLOADER_ENABLED", + "RENV_AUTOLOADER_ENABLED", + "RENV_ACTIVATE_PROJECT" + ) + + for (envvar in envvars) { + envval <- Sys.getenv(envvar, unset = NA) + if (!is.na(envval)) + return(tolower(envval) %in% c("true", "t", "1")) + } + + # enable by default + TRUE + + }) + + # bail if we're not enabled + if (!enabled) { + + # if we're not enabled, we might still need to manually load + # the user profile here + profile <- Sys.getenv("R_PROFILE_USER", unset = "~/.Rprofile") + if (file.exists(profile)) { + cfg <- Sys.getenv("RENV_CONFIG_USER_PROFILE", unset = "TRUE") + if (tolower(cfg) %in% c("true", "t", "1")) + sys.source(profile, envir = globalenv()) + } + + return(FALSE) + + } + + # avoid recursion + if (identical(getOption("renv.autoloader.running"), TRUE)) { + warning("ignoring recursive attempt to run renv autoloader") + return(invisible(TRUE)) + } + + # signal that we're loading renv during R startup + options(renv.autoloader.running = TRUE) + on.exit(options(renv.autoloader.running = NULL), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # unload renv if it's already been loaded + if ("renv" %in% loadedNamespaces()) + unloadNamespace("renv") + + # load bootstrap tools + `%||%` <- function(x, y) { + if (is.null(x)) y else x + } + + catf <- function(fmt, ..., appendLF = TRUE) { + + quiet <- getOption("renv.bootstrap.quiet", default = FALSE) + if (quiet) + return(invisible()) + + msg <- sprintf(fmt, ...) + cat(msg, file = stdout(), sep = if (appendLF) "\n" else "") + + invisible(msg) + + } + + header <- function(label, + ..., + prefix = "#", + suffix = "-", + n = min(getOption("width"), 78)) + { + label <- sprintf(label, ...) + n <- max(n - nchar(label) - nchar(prefix) - 2L, 8L) + if (n <= 0) + return(paste(prefix, label)) + + tail <- paste(rep.int(suffix, n), collapse = "") + paste0(prefix, " ", label, " ", tail) + + } + + heredoc <- function(text, leave = 0) { + + # remove leading, trailing whitespace + trimmed <- gsub("^\\s*\\n|\\n\\s*$", "", text) + + # split into lines + lines <- strsplit(trimmed, "\n", fixed = TRUE)[[1L]] + + # compute common indent + indent <- regexpr("[^[:space:]]", lines) + common <- min(setdiff(indent, -1L)) - leave + paste(substring(lines, common), collapse = "\n") + + } + + startswith <- function(string, prefix) { + substring(string, 1, nchar(prefix)) == prefix + } + + bootstrap <- function(version, library) { + + friendly <- renv_bootstrap_version_friendly(version) + section <- header(sprintf("Bootstrapping renv %s", friendly)) + catf(section) + + # attempt to download renv + catf("- Downloading renv ... ", appendLF = FALSE) + withCallingHandlers( + tarball <- renv_bootstrap_download(version), + error = function(err) { + catf("FAILED") + stop("failed to download:\n", conditionMessage(err)) + } + ) + catf("OK") + on.exit(unlink(tarball), add = TRUE) + + # now attempt to install + catf("- Installing renv ... ", appendLF = FALSE) + withCallingHandlers( + status <- renv_bootstrap_install(version, tarball, library), + error = function(err) { + catf("FAILED") + stop("failed to install:\n", conditionMessage(err)) + } + ) + catf("OK") + + # add empty line to break up bootstrapping from normal output + catf("") + + return(invisible()) + } + + renv_bootstrap_tests_running <- function() { + getOption("renv.tests.running", default = FALSE) + } + + renv_bootstrap_repos <- function() { + + # get CRAN repository + cran <- getOption("renv.repos.cran", "https://cloud.r-project.org") + + # check for repos override + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (!is.na(repos)) { + + # check for RSPM; if set, use a fallback repository for renv + rspm <- Sys.getenv("RSPM", unset = NA) + if (identical(rspm, repos)) + repos <- c(RSPM = rspm, CRAN = cran) + + return(repos) + + } + + # check for lockfile repositories + repos <- tryCatch(renv_bootstrap_repos_lockfile(), error = identity) + if (!inherits(repos, "error") && length(repos)) + return(repos) + + # retrieve current repos + repos <- getOption("repos") + + # ensure @CRAN@ entries are resolved + repos[repos == "@CRAN@"] <- cran + + # add in renv.bootstrap.repos if set + default <- c(FALLBACK = "https://cloud.r-project.org") + extra <- getOption("renv.bootstrap.repos", default = default) + repos <- c(repos, extra) + + # remove duplicates that might've snuck in + dupes <- duplicated(repos) | duplicated(names(repos)) + repos[!dupes] + + } + + renv_bootstrap_repos_lockfile <- function() { + + lockpath <- Sys.getenv("RENV_PATHS_LOCKFILE", unset = "renv.lock") + if (!file.exists(lockpath)) + return(NULL) + + lockfile <- tryCatch(renv_json_read(lockpath), error = identity) + if (inherits(lockfile, "error")) { + warning(lockfile) + return(NULL) + } + + repos <- lockfile$R$Repositories + if (length(repos) == 0) + return(NULL) + + keys <- vapply(repos, `[[`, "Name", FUN.VALUE = character(1)) + vals <- vapply(repos, `[[`, "URL", FUN.VALUE = character(1)) + names(vals) <- keys + + return(vals) + + } + + renv_bootstrap_download <- function(version) { + + sha <- attr(version, "sha", exact = TRUE) + + methods <- if (!is.null(sha)) { + + # attempting to bootstrap a development version of renv + c( + function() renv_bootstrap_download_tarball(sha), + function() renv_bootstrap_download_github(sha) + ) + + } else { + + # attempting to bootstrap a release version of renv + c( + function() renv_bootstrap_download_tarball(version), + function() renv_bootstrap_download_cran_latest(version), + function() renv_bootstrap_download_cran_archive(version) + ) + + } + + for (method in methods) { + path <- tryCatch(method(), error = identity) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("All download methods failed") + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + args <- list( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + if ("headers" %in% names(formals(utils::download.file))) + args$headers <- renv_bootstrap_download_custom_headers(url) + + do.call(utils::download.file, args) + + } + + renv_bootstrap_download_custom_headers <- function(url) { + + headers <- getOption("renv.download.headers") + if (is.null(headers)) + return(character()) + + if (!is.function(headers)) + stopf("'renv.download.headers' is not a function") + + headers <- headers(url) + if (length(headers) == 0L) + return(character()) + + if (is.list(headers)) + headers <- unlist(headers, recursive = FALSE, use.names = TRUE) + + ok <- + is.character(headers) && + is.character(names(headers)) && + all(nzchar(names(headers))) + + if (!ok) + stop("invocation of 'renv.download.headers' did not return a named character vector") + + headers + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + spec <- renv_bootstrap_download_cran_latest_find(version) + type <- spec$type + repos <- spec$repos + + baseurl <- utils::contrib.url(repos = repos, type = type) + ext <- if (identical(type, "source")) + ".tar.gz" + else if (Sys.info()[["sysname"]] == "Windows") + ".zip" + else + ".tgz" + name <- sprintf("renv_%s%s", version, ext) + url <- paste(baseurl, name, sep = "/") + + destfile <- file.path(tempdir(), name) + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (inherits(status, "condition")) + return(FALSE) + + # report success and return + destfile + + } + + renv_bootstrap_download_cran_latest_find <- function(version) { + + # check whether binaries are supported on this system + binary <- + getOption("renv.bootstrap.binary", default = TRUE) && + !identical(.Platform$pkgType, "source") && + !identical(getOption("pkgType"), "source") && + Sys.info()[["sysname"]] %in% c("Darwin", "Windows") + + types <- c(if (binary) "binary", "source") + + # iterate over types + repositories + for (type in types) { + for (repos in renv_bootstrap_repos()) { + + # retrieve package database + db <- tryCatch( + as.data.frame( + utils::available.packages(type = type, repos = repos), + stringsAsFactors = FALSE + ), + error = identity + ) + + if (inherits(db, "error")) + next + + # check for compatible entry + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) + next + + # found it; return spec to caller + spec <- list(entry = entry, type = type, repos = repos) + return(spec) + + } + } + + # if we got here, we failed to find renv + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- renv_bootstrap_repos() + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) + return(destfile) + + } + + return(FALSE) + + } + + renv_bootstrap_download_tarball <- function(version) { + + # if the user has provided the path to a tarball via + # an environment variable, then use it + tarball <- Sys.getenv("RENV_BOOTSTRAP_TARBALL", unset = NA) + if (is.na(tarball)) + return() + + # allow directories + if (dir.exists(tarball)) { + name <- sprintf("renv_%s.tar.gz", version) + tarball <- file.path(tarball, name) + } + + # bail if it doesn't exist + if (!file.exists(tarball)) { + + # let the user know we weren't able to honour their request + fmt <- "- RENV_BOOTSTRAP_TARBALL is set (%s) but does not exist." + msg <- sprintf(fmt, tarball) + warning(msg) + + # bail + return() + + } + + catf("- Using local tarball '%s'.", tarball) + tarball + + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) + return(FALSE) + + renv_bootstrap_download_augment(destfile) + + return(destfile) + + } + + # Add Sha to DESCRIPTION. This is stop gap until #890, after which we + # can use renv::install() to fully capture metadata. + renv_bootstrap_download_augment <- function(destfile) { + sha <- renv_bootstrap_git_extract_sha1_tar(destfile) + if (is.null(sha)) { + return() + } + + # Untar + tempdir <- tempfile("renv-github-") + on.exit(unlink(tempdir, recursive = TRUE), add = TRUE) + untar(destfile, exdir = tempdir) + pkgdir <- dir(tempdir, full.names = TRUE)[[1]] + + # Modify description + desc_path <- file.path(pkgdir, "DESCRIPTION") + desc_lines <- readLines(desc_path) + remotes_fields <- c( + "RemoteType: github", + "RemoteHost: api.github.com", + "RemoteRepo: renv", + "RemoteUsername: rstudio", + "RemotePkgRef: rstudio/renv", + paste("RemoteRef: ", sha), + paste("RemoteSha: ", sha) + ) + writeLines(c(desc_lines[desc_lines != ""], remotes_fields), con = desc_path) + + # Re-tar + local({ + old <- setwd(tempdir) + on.exit(setwd(old), add = TRUE) + + tar(destfile, compression = "gzip") + }) + invisible() + } + + # Extract the commit hash from a git archive. Git archives include the SHA1 + # hash as the comment field of the tarball pax extended header + # (see https://www.kernel.org/pub/software/scm/git/docs/git-archive.html) + # For GitHub archives this should be the first header after the default one + # (512 byte) header. + renv_bootstrap_git_extract_sha1_tar <- function(bundle) { + + # open the bundle for reading + # We use gzcon for everything because (from ?gzcon) + # > Reading from a connection which does not supply a 'gzip' magic + # > header is equivalent to reading from the original connection + conn <- gzcon(file(bundle, open = "rb", raw = TRUE)) + on.exit(close(conn)) + + # The default pax header is 512 bytes long and the first pax extended header + # with the comment should be 51 bytes long + # `52 comment=` (11 chars) + 40 byte SHA1 hash + len <- 0x200 + 0x33 + res <- rawToChar(readBin(conn, "raw", n = len)[0x201:len]) + + if (grepl("^52 comment=", res)) { + sub("52 comment=", "", res) + } else { + NULL + } + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + dir.create(library, showWarnings = FALSE, recursive = TRUE) + output <- renv_bootstrap_install_impl(library, tarball) + + # check for successful install + status <- attr(output, "status") + if (is.null(status) || identical(status, 0L)) + return(status) + + # an error occurred; report it + header <- "installation of renv failed" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- paste(c(header, lines, output), collapse = "\n") + stop(text) + + } + + renv_bootstrap_install_impl <- function(library, tarball) { + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + R <- file.path(bin, exe) + + args <- c( + "--vanilla", "CMD", "INSTALL", "--no-multiarch", + "-l", shQuote(path.expand(library)), + shQuote(path.expand(tarball)) + ) + + system2(R, args, stdout = TRUE, stderr = TRUE) + + } + + renv_bootstrap_platform_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- renv_bootstrap_platform_prefix_impl() + if (!is.na(prefix) && nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_platform_prefix_impl <- function() { + + # if an explicit prefix has been supplied, use it + prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) + if (!is.na(prefix)) + return(prefix) + + # if the user has requested an automatic prefix, generate it + auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (is.na(auto) && getRversion() >= "4.4.0") + auto <- "TRUE" + + if (auto %in% c("TRUE", "True", "true", "1")) + return(renv_bootstrap_platform_prefix_auto()) + + # empty string on failure + "" + + } + + renv_bootstrap_platform_prefix_auto <- function() { + + prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) + if (inherits(prefix, "error") || prefix %in% "unknown") { + + msg <- paste( + "failed to infer current operating system", + "please file a bug report at https://github.com/rstudio/renv/issues", + sep = "; " + ) + + warning(msg) + + } + + prefix + + } + + renv_bootstrap_platform_os <- function() { + + sysinfo <- Sys.info() + sysname <- sysinfo[["sysname"]] + + # handle Windows + macOS up front + if (sysname == "Windows") + return("windows") + else if (sysname == "Darwin") + return("macos") + + # check for os-release files + for (file in c("/etc/os-release", "/usr/lib/os-release")) + if (file.exists(file)) + return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) + + # check for redhat-release files + if (file.exists("/etc/redhat-release")) + return(renv_bootstrap_platform_os_via_redhat_release()) + + "unknown" + + } + + renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { + + # read /etc/os-release + release <- utils::read.table( + file = file, + sep = "=", + quote = c("\"", "'"), + col.names = c("Key", "Value"), + comment.char = "#", + stringsAsFactors = FALSE + ) + + vars <- as.list(release$Value) + names(vars) <- release$Key + + # get os name + os <- tolower(sysinfo[["sysname"]]) + + # read id + id <- "unknown" + for (field in c("ID", "ID_LIKE")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + id <- vars[[field]] + break + } + } + + # read version + version <- "unknown" + for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + version <- vars[[field]] + break + } + } + + # join together + paste(c(os, id, version), collapse = "-") + + } + + renv_bootstrap_platform_os_via_redhat_release <- function() { + + # read /etc/redhat-release + contents <- readLines("/etc/redhat-release", warn = FALSE) + + # infer id + id <- if (grepl("centos", contents, ignore.case = TRUE)) + "centos" + else if (grepl("redhat", contents, ignore.case = TRUE)) + "redhat" + else + "unknown" + + # try to find a version component (very hacky) + version <- "unknown" + + parts <- strsplit(contents, "[[:space:]]")[[1L]] + for (part in parts) { + + nv <- tryCatch(numeric_version(part), error = identity) + if (inherits(nv, "error")) + next + + version <- nv[1, 1] + break + + } + + paste(c("linux", id, version), collapse = "-") + + } + + renv_bootstrap_library_root_name <- function(project) { + + # use project name as-is if requested + asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") + if (asis) + return(basename(project)) + + # otherwise, disambiguate based on project's path + id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) + paste(basename(project), id, sep = "-") + + } + + renv_bootstrap_library_root <- function(project) { + + prefix <- renv_bootstrap_profile_prefix() + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(paste(c(path, prefix), collapse = "/")) + + path <- renv_bootstrap_library_root_impl(project) + if (!is.null(path)) { + name <- renv_bootstrap_library_root_name(project) + return(paste(c(path, prefix, name), collapse = "/")) + } + + renv_bootstrap_paths_renv("library", project = project) + + } + + renv_bootstrap_library_root_impl <- function(project) { + + root <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(root)) + return(root) + + type <- renv_bootstrap_project_type(project) + if (identical(type, "package")) { + userdir <- renv_bootstrap_user_dir() + return(file.path(userdir, "library")) + } + + } + + renv_bootstrap_validate_version <- function(version, description = NULL) { + + # resolve description file + # + # avoid passing lib.loc to `packageDescription()` below, since R will + # use the loaded version of the package by default anyhow. note that + # this function should only be called after 'renv' is loaded + # https://github.com/rstudio/renv/issues/1625 + description <- description %||% packageDescription("renv") + + # check whether requested version 'version' matches loaded version of renv + sha <- attr(version, "sha", exact = TRUE) + valid <- if (!is.null(sha)) + renv_bootstrap_validate_version_dev(sha, description) + else + renv_bootstrap_validate_version_release(version, description) + + if (valid) + return(TRUE) + + # the loaded version of renv doesn't match the requested version; + # give the user instructions on how to proceed + dev <- identical(description[["RemoteType"]], "github") + remote <- if (dev) + paste("rstudio/renv", description[["RemoteSha"]], sep = "@") + else + paste("renv", description[["Version"]], sep = "@") + + # display both loaded version + sha if available + friendly <- renv_bootstrap_version_friendly( + version = description[["Version"]], + sha = if (dev) description[["RemoteSha"]] + ) + + fmt <- heredoc(" + renv %1$s was loaded from project library, but this project is configured to use renv %2$s. + - Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile. + - Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library. + ") + catf(fmt, friendly, renv_bootstrap_version_friendly(version), remote) + + FALSE + + } + + renv_bootstrap_validate_version_dev <- function(version, description) { + expected <- description[["RemoteSha"]] + is.character(expected) && startswith(expected, version) + } + + renv_bootstrap_validate_version_release <- function(version, description) { + expected <- description[["Version"]] + is.character(expected) && identical(expected, version) + } + + renv_bootstrap_hash_text <- function(text) { + + hashfile <- tempfile("renv-hash-") + on.exit(unlink(hashfile), add = TRUE) + + writeLines(text, con = hashfile) + tools::md5sum(hashfile) + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # execute renv load hooks, if any + hooks <- getHook("renv::autoload") + for (hook in hooks) + if (is.function(hook)) + tryCatch(hook(), error = warnify) + + # load the project + renv::load(project) + + TRUE + + } + + renv_bootstrap_profile_load <- function(project) { + + # if RENV_PROFILE is already set, just use that + profile <- Sys.getenv("RENV_PROFILE", unset = NA) + if (!is.na(profile) && nzchar(profile)) + return(profile) + + # check for a profile file (nothing to do if it doesn't exist) + path <- renv_bootstrap_paths_renv("profile", profile = FALSE, project = project) + if (!file.exists(path)) + return(NULL) + + # read the profile, and set it if it exists + contents <- readLines(path, warn = FALSE) + if (length(contents) == 0L) + return(NULL) + + # set RENV_PROFILE + profile <- contents[[1L]] + if (!profile %in% c("", "default")) + Sys.setenv(RENV_PROFILE = profile) + + profile + + } + + renv_bootstrap_profile_prefix <- function() { + profile <- renv_bootstrap_profile_get() + if (!is.null(profile)) + return(file.path("profiles", profile, "renv")) + } + + renv_bootstrap_profile_get <- function() { + profile <- Sys.getenv("RENV_PROFILE", unset = "") + renv_bootstrap_profile_normalize(profile) + } + + renv_bootstrap_profile_set <- function(profile) { + profile <- renv_bootstrap_profile_normalize(profile) + if (is.null(profile)) + Sys.unsetenv("RENV_PROFILE") + else + Sys.setenv(RENV_PROFILE = profile) + } + + renv_bootstrap_profile_normalize <- function(profile) { + + if (is.null(profile) || profile %in% c("", "default")) + return(NULL) + + profile + + } + + renv_bootstrap_path_absolute <- function(path) { + + substr(path, 1L, 1L) %in% c("~", "/", "\\") || ( + substr(path, 1L, 1L) %in% c(letters, LETTERS) && + substr(path, 2L, 3L) %in% c(":/", ":\\") + ) + + } + + renv_bootstrap_paths_renv <- function(..., profile = TRUE, project = NULL) { + renv <- Sys.getenv("RENV_PATHS_RENV", unset = "renv") + root <- if (renv_bootstrap_path_absolute(renv)) NULL else project + prefix <- if (profile) renv_bootstrap_profile_prefix() + components <- c(root, renv, prefix, ...) + paste(components, collapse = "/") + } + + renv_bootstrap_project_type <- function(path) { + + descpath <- file.path(path, "DESCRIPTION") + if (!file.exists(descpath)) + return("unknown") + + desc <- tryCatch( + read.dcf(descpath, all = TRUE), + error = identity + ) + + if (inherits(desc, "error")) + return("unknown") + + type <- desc$Type + if (!is.null(type)) + return(tolower(type)) + + package <- desc$Package + if (!is.null(package)) + return("package") + + "unknown" + + } + + renv_bootstrap_user_dir <- function() { + dir <- renv_bootstrap_user_dir_impl() + path.expand(chartr("\\", "/", dir)) + } + + renv_bootstrap_user_dir_impl <- function() { + + # use local override if set + override <- getOption("renv.userdir.override") + if (!is.null(override)) + return(override) + + # use R_user_dir if available + tools <- asNamespace("tools") + if (is.function(tools$R_user_dir)) + return(tools$R_user_dir("renv", "cache")) + + # try using our own backfill for older versions of R + envvars <- c("R_USER_CACHE_DIR", "XDG_CACHE_HOME") + for (envvar in envvars) { + root <- Sys.getenv(envvar, unset = NA) + if (!is.na(root)) + return(file.path(root, "R/renv")) + } + + # use platform-specific default fallbacks + if (Sys.info()[["sysname"]] == "Windows") + file.path(Sys.getenv("LOCALAPPDATA"), "R/cache/R/renv") + else if (Sys.info()[["sysname"]] == "Darwin") + "~/Library/Caches/org.R-project.R/R/renv" + else + "~/.cache/R/renv" + + } + + renv_bootstrap_version_friendly <- function(version, shafmt = NULL, sha = NULL) { + sha <- sha %||% attr(version, "sha", exact = TRUE) + parts <- c(version, sprintf(shafmt %||% " [sha: %s]", substring(sha, 1L, 7L))) + paste(parts, collapse = "") + } + + renv_bootstrap_exec <- function(project, libpath, version) { + if (!renv_bootstrap_load(project, libpath, version)) + renv_bootstrap_run(version, libpath) + } + + renv_bootstrap_run <- function(version, libpath) { + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + return(renv::load(project = getwd())) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + + } + + renv_json_read <- function(file = NULL, text = NULL) { + + jlerr <- NULL + + # if jsonlite is loaded, use that instead + if ("jsonlite" %in% loadedNamespaces()) { + + json <- tryCatch(renv_json_read_jsonlite(file, text), error = identity) + if (!inherits(json, "error")) + return(json) + + jlerr <- json + + } + + # otherwise, fall back to the default JSON reader + json <- tryCatch(renv_json_read_default(file, text), error = identity) + if (!inherits(json, "error")) + return(json) + + # report an error + if (!is.null(jlerr)) + stop(jlerr) + else + stop(json) + + } + + renv_json_read_jsonlite <- function(file = NULL, text = NULL) { + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") + jsonlite::fromJSON(txt = text, simplifyVector = FALSE) + } + + renv_json_read_default <- function(file = NULL, text = NULL) { + + # find strings in the JSON + text <- paste(text %||% readLines(file, warn = FALSE), collapse = "\n") + pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]' + locs <- gregexpr(pattern, text, perl = TRUE)[[1]] + + # if any are found, replace them with placeholders + replaced <- text + strings <- character() + replacements <- character() + + if (!identical(c(locs), -1L)) { + + # get the string values + starts <- locs + ends <- locs + attr(locs, "match.length") - 1L + strings <- substring(text, starts, ends) + + # only keep those requiring escaping + strings <- grep("[[\\]{}:]", strings, perl = TRUE, value = TRUE) + + # compute replacements + replacements <- sprintf('"\032%i\032"', seq_along(strings)) + + # replace the strings + mapply(function(string, replacement) { + replaced <<- sub(string, replacement, replaced, fixed = TRUE) + }, strings, replacements) + + } + + # transform the JSON into something the R parser understands + transformed <- replaced + transformed <- gsub("{}", "`names<-`(list(), character())", transformed, fixed = TRUE) + transformed <- gsub("[[{]", "list(", transformed, perl = TRUE) + transformed <- gsub("[]}]", ")", transformed, perl = TRUE) + transformed <- gsub(":", "=", transformed, fixed = TRUE) + text <- paste(transformed, collapse = "\n") + + # parse it + json <- parse(text = text, keep.source = FALSE, srcfile = NULL)[[1L]] + + # construct map between source strings, replaced strings + map <- as.character(parse(text = strings)) + names(map) <- as.character(parse(text = replacements)) + + # convert to list + map <- as.list(map) + + # remap strings in object + remapped <- renv_json_read_remap(json, map) + + # evaluate + eval(remapped, envir = baseenv()) + + } + + renv_json_read_remap <- function(json, map) { + + # fix names + if (!is.null(names(json))) { + lhs <- match(names(json), names(map), nomatch = 0L) + rhs <- match(names(map), names(json), nomatch = 0L) + names(json)[rhs] <- map[lhs] + } + + # fix values + if (is.character(json)) + return(map[[json]] %||% json) + + # handle true, false, null + if (is.name(json)) { + text <- as.character(json) + if (text == "true") + return(TRUE) + else if (text == "false") + return(FALSE) + else if (text == "null") + return(NULL) + } + + # recurse + if (is.recursive(json)) { + for (i in seq_along(json)) { + json[i] <- list(renv_json_read_remap(json[[i]], map)) + } + } + + json + + } + + # load the renv profile, if any + renv_bootstrap_profile_load(project) + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_platform_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # run bootstrap code + renv_bootstrap_exec(project, libpath, version) + + invisible() + +}) diff --git a/renv/settings.json b/renv/settings.json new file mode 100644 index 0000000..74c1d4b --- /dev/null +++ b/renv/settings.json @@ -0,0 +1,19 @@ +{ + "bioconductor.version": null, + "external.libraries": [], + "ignored.packages": [], + "package.dependency.fields": [ + "Imports", + "Depends", + "LinkingTo" + ], + "ppm.enabled": null, + "ppm.ignored.urls": [], + "r.version": null, + "snapshot.type": "explicit", + "use.cache": true, + "vcs.ignore.cellar": true, + "vcs.ignore.library": true, + "vcs.ignore.local": true, + "vcs.manage.ignores": true +} From 83b70f10baf7df44486f0b288ac31cedf5cd4798 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 14:58:11 +0100 Subject: [PATCH 02/21] Add in existing bundles --- data/raw/HBA1c.csv | 4 ++ data/raw/LDH.csv | 3 ++ data/raw/antibodies_to_hiv.csv | 3 ++ data/raw/antigens.csv | 29 +++++++++++ data/raw/blood_antibodies.csv | 60 ++++++++++++++++++++++ data/raw/bone_profile.csv | 6 +++ data/raw/covid_antibody_levels.csv | 3 ++ data/raw/eGFR.csv | 2 + data/raw/full_blood_count_differential.csv | 18 +++++++ data/raw/haemoglobin.csv | 10 ++++ data/raw/haptoglobin.csv | 3 ++ data/raw/height_and_weight.csv | 3 ++ data/raw/hepatitis_b_screening.csv | 4 ++ data/raw/hepatitis_c_screening.csv | 3 ++ data/raw/immunofixation_chains.csv | 8 +++ data/raw/immunoglobulins.csv | 6 +++ data/raw/indices_of_deprivation.csv | 3 ++ data/raw/light_chains.csv | 5 ++ data/raw/liver_function_test.csv | 5 ++ data/raw/liver_profile.csv | 5 ++ data/raw/monoclonal_bands.csv | 5 ++ data/raw/plasma_viscosity.csv | 3 ++ data/raw/renal_profile.csv | 5 ++ data/raw/serum_albumin.csv | 3 ++ data/raw/serum_beta_2_microglobulin.csv | 3 ++ data/raw/serum_corrected_calcium.csv | 2 + data/raw/serum_creatinine.csv | 2 + data/raw/serum_glucose.csv | 2 + data/raw/serum_immunofixation.csv | 3 ++ data/raw/serum_urea.csv | 2 + data/raw/smoking.csv | 7 +++ data/raw/snomed_race.csv | 19 +++++++ data/raw/thyroid_profile.csv | 3 ++ data/raw/total_protein.csv | 3 ++ data/raw/urea_electrolyte.csv | 6 +++ data/raw/urine_albumin.csv | 3 ++ data/raw/urine_bence_jones_protein.csv | 8 +++ 37 files changed, 262 insertions(+) create mode 100644 data/raw/HBA1c.csv create mode 100644 data/raw/LDH.csv create mode 100644 data/raw/antibodies_to_hiv.csv create mode 100644 data/raw/antigens.csv create mode 100644 data/raw/blood_antibodies.csv create mode 100644 data/raw/bone_profile.csv create mode 100644 data/raw/covid_antibody_levels.csv create mode 100644 data/raw/eGFR.csv create mode 100644 data/raw/full_blood_count_differential.csv create mode 100644 data/raw/haemoglobin.csv create mode 100644 data/raw/haptoglobin.csv create mode 100644 data/raw/height_and_weight.csv create mode 100644 data/raw/hepatitis_b_screening.csv create mode 100644 data/raw/hepatitis_c_screening.csv create mode 100644 data/raw/immunofixation_chains.csv create mode 100644 data/raw/immunoglobulins.csv create mode 100644 data/raw/indices_of_deprivation.csv create mode 100644 data/raw/light_chains.csv create mode 100644 data/raw/liver_function_test.csv create mode 100644 data/raw/liver_profile.csv create mode 100644 data/raw/monoclonal_bands.csv create mode 100644 data/raw/plasma_viscosity.csv create mode 100644 data/raw/renal_profile.csv create mode 100644 data/raw/serum_albumin.csv create mode 100644 data/raw/serum_beta_2_microglobulin.csv create mode 100644 data/raw/serum_corrected_calcium.csv create mode 100644 data/raw/serum_creatinine.csv create mode 100644 data/raw/serum_glucose.csv create mode 100644 data/raw/serum_immunofixation.csv create mode 100644 data/raw/serum_urea.csv create mode 100644 data/raw/smoking.csv create mode 100644 data/raw/snomed_race.csv create mode 100644 data/raw/thyroid_profile.csv create mode 100644 data/raw/total_protein.csv create mode 100644 data/raw/urea_electrolyte.csv create mode 100644 data/raw/urine_albumin.csv create mode 100644 data/raw/urine_bence_jones_protein.csv diff --git a/data/raw/HBA1c.csv b/data/raw/HBA1c.csv new file mode 100644 index 0000000..5c56e80 --- /dev/null +++ b/data/raw/HBA1c.csv @@ -0,0 +1,4 @@ +concept_id,allowed,per_person,min,max +3005673,T,1,0, +40762352,T,1,0, + diff --git a/data/raw/LDH.csv b/data/raw/LDH.csv new file mode 100644 index 0000000..269d2ac --- /dev/null +++ b/data/raw/LDH.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3022250,T,1,0, + diff --git a/data/raw/antibodies_to_hiv.csv b/data/raw/antibodies_to_hiv.csv new file mode 100644 index 0000000..707dce1 --- /dev/null +++ b/data/raw/antibodies_to_hiv.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +40760007,T,1,0, + diff --git a/data/raw/antigens.csv b/data/raw/antigens.csv new file mode 100644 index 0000000..2f951b8 --- /dev/null +++ b/data/raw/antigens.csv @@ -0,0 +1,29 @@ +concept_id,allowed,per_person,min,max +3003573,T,0,, +3021714,T,0,, +40761161,T,0,, +3005480,T,0,, +3037821,T,0,, +3033876,T,0,, +3024448,T,0,, +3010024,T,0,, +3002394,T,0,, +3001884,T,0,, +3013356,T,0,, +3013154,T,0,, +3013506,T,0,, +3023848,T,0,, +3026396,T,0,, +3028568,T,0,, +3037596,T,0,, +3007188,T,0,, +3019597,T,0,, +3005186,T,0,, +3005222,T,0,, +3008387,T,0,, +3006768,T,0,, +37062741,T,0,, +37051745,T,0,, +37020250,T,0,, +37021506,T,0,, +37021365,T,0,, \ No newline at end of file diff --git a/data/raw/blood_antibodies.csv b/data/raw/blood_antibodies.csv new file mode 100644 index 0000000..2e4ff35 --- /dev/null +++ b/data/raw/blood_antibodies.csv @@ -0,0 +1,60 @@ +concept_id,allowed,per_person,min,max +3016598,T,0,, +3022247,T,0,, +3014694,T,0,, +3022924,T,0,, +40768029,T,0,, +3038770,T,0,, +3039113,T,0,, +3020342,T,0,, +3015654,T,0,, +3008003,T,0,, +3007705,T,0,, +40761160,T,0,, +3001981,T,0,, +3015600,T,0,, +3002402,T,0,, +3002171,T,0,, +3001819,T,0,, +40768018,T,0,, +3017125,T,0,, +3037405,T,0,, +40761162,T,0,, +3017800,T,0,, +3053246,T,0,, +3016597,T,0,, +3020920,T,0,, +3010889,T,0,, +3026722,T,0,, +40768022,T,0,, +3027304,T,0,, +3005119,T,0,, +3021816,T,0,, +3005386,T,0,, +40761169,T,0,, +3034851,T,0,, +3034176,T,0,, +3035056,T,0,, +3014586,T,0,, +3005723,T,0,, +3024811,T,0,, +3014995,T,0,, +3021215,T,0,, +3026986,T,0,, +40761173,T,0,, +3003351,T,0,, +3017860,T,0,, +40758467,T,0,, +3002134,T,0,, +3001631,T,0,, +40761182,T,0,, +40761185,T,0,, +40761175,T,0,, +40768037,T,0,, +3011656,T,0,, +40761177,T,0,, +3012260,T,0,, +3012905,T,0,, +3025123,T,0,, +3965130,T,0,, +40771894,T,0,, \ No newline at end of file diff --git a/data/raw/bone_profile.csv b/data/raw/bone_profile.csv new file mode 100644 index 0000000..5f31456 --- /dev/null +++ b/data/raw/bone_profile.csv @@ -0,0 +1,6 @@ +concept_id,allowed,per_person,min,max +3035995,T,1,0, +3024561,T,1,0, +3015377,T,1,0, +3020059,T,1,0, +3003458,T,1,0, diff --git a/data/raw/covid_antibody_levels.csv b/data/raw/covid_antibody_levels.csv new file mode 100644 index 0000000..d392480 --- /dev/null +++ b/data/raw/covid_antibody_levels.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +1988202,T,1,0, +1988397,T,1,0, diff --git a/data/raw/eGFR.csv b/data/raw/eGFR.csv new file mode 100644 index 0000000..0bd4ce4 --- /dev/null +++ b/data/raw/eGFR.csv @@ -0,0 +1,2 @@ +concept_id,allowed,per_person,min,max +46236952,T,1,0, diff --git a/data/raw/full_blood_count_differential.csv b/data/raw/full_blood_count_differential.csv new file mode 100644 index 0000000..8a66f32 --- /dev/null +++ b/data/raw/full_blood_count_differential.csv @@ -0,0 +1,18 @@ +concept_id,allowed,per_person,min,max +3010813,T,1,0, +3026361,T,1,0, +3000963,T,1,0, +3009542,T,1,0, +3024731,T,1,0, +3035941,T,1,0, +3003338,T,1,0, +3002385,T,1,0, +3007461,T,1,0, +3001123,T,1,0, +3017732,T,1,0, +3019198,T,1,0, +3001604,T,1,0, +3013115,T,1,0, +3006315,T,1,0, +3034708,T,1,0, +3001490,T,1,0, \ No newline at end of file diff --git a/data/raw/haemoglobin.csv b/data/raw/haemoglobin.csv new file mode 100644 index 0000000..51acf8c --- /dev/null +++ b/data/raw/haemoglobin.csv @@ -0,0 +1,10 @@ +concept_id,allowed,per_person,min,max +3031973,T,0,0 +3037653,T,0,0 +3029071,T,0,0 +42869613,T,0,0 +3045566,T,0,0 +3046405,T,0,0 +3046708,T,0,0 +3045566,T,0,0 +3046405,T,0,0 \ No newline at end of file diff --git a/data/raw/haptoglobin.csv b/data/raw/haptoglobin.csv new file mode 100644 index 0000000..332dded --- /dev/null +++ b/data/raw/haptoglobin.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3012336,T,0, +42868683,T,0, \ No newline at end of file diff --git a/data/raw/height_and_weight.csv b/data/raw/height_and_weight.csv new file mode 100644 index 0000000..e3465d0 --- /dev/null +++ b/data/raw/height_and_weight.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +4177340,T,1,0, +4099154,T,1,0, \ No newline at end of file diff --git a/data/raw/hepatitis_b_screening.csv b/data/raw/hepatitis_b_screening.csv new file mode 100644 index 0000000..faec923 --- /dev/null +++ b/data/raw/hepatitis_b_screening.csv @@ -0,0 +1,4 @@ +concept_id,allowed,per_person,min,max +3019284,T,1,0, +3036282,T,1,0, +3013731,T,1,0, \ No newline at end of file diff --git a/data/raw/hepatitis_c_screening.csv b/data/raw/hepatitis_c_screening.csv new file mode 100644 index 0000000..5038655 --- /dev/null +++ b/data/raw/hepatitis_c_screening.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3013801,T,1,0, +3018447,T,0,0, \ No newline at end of file diff --git a/data/raw/immunofixation_chains.csv b/data/raw/immunofixation_chains.csv new file mode 100644 index 0000000..995e81a --- /dev/null +++ b/data/raw/immunofixation_chains.csv @@ -0,0 +1,8 @@ +concept_id,concept_name,allowed,per_person,min,max +3020508,IgA [Presence] in Serum by Immunofixation,TRUE,1,NA,NA +3026687,IgG [Presence] in Serum by Immunofixation,TRUE,1,NA,NA +3009762,IgM [Presence] in Serum by Immunofixation,TRUE,1,NA,NA +3005427,IgD [Presence] in Serum by Immunofixation,TRUE,1,NA,NA +3000841,IgE [Presence] in Serum by Immunofixation,TRUE,1,NA,NA +3047350,Kappa light chains.free [Presence] in Serum by Immunofixation,TRUE,1,NA,NA +3030207,Lambda light chains.free [Presence] in Serum by Immunofixation,TRUE,1,NA,NA diff --git a/data/raw/immunoglobulins.csv b/data/raw/immunoglobulins.csv new file mode 100644 index 0000000..ed64249 --- /dev/null +++ b/data/raw/immunoglobulins.csv @@ -0,0 +1,6 @@ +concept_id,allowed,per_person,min,max +3007164,T,1,0, +3028026,T,1,0, +3005719,T,1,0, +40759807,T,1,0, +3005322,T,1,0, \ No newline at end of file diff --git a/data/raw/indices_of_deprivation.csv b/data/raw/indices_of_deprivation.csv new file mode 100644 index 0000000..f93049f --- /dev/null +++ b/data/raw/indices_of_deprivation.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +35812882,T,0,0, + diff --git a/data/raw/light_chains.csv b/data/raw/light_chains.csv new file mode 100644 index 0000000..abf3005 --- /dev/null +++ b/data/raw/light_chains.csv @@ -0,0 +1,5 @@ +concept_id,allowed,per_person,min,max +3034860,T,1,0, +3047169,T,1,0, +3053209,T,1,0, + diff --git a/data/raw/liver_function_test.csv b/data/raw/liver_function_test.csv new file mode 100644 index 0000000..d58aea6 --- /dev/null +++ b/data/raw/liver_function_test.csv @@ -0,0 +1,5 @@ +concept_id,allowed,per_person,min,max +3006140,T,1,0, +3035995,T,1,0, +3005755,T,1,0, +3024561,T,1,0, diff --git a/data/raw/liver_profile.csv b/data/raw/liver_profile.csv new file mode 100644 index 0000000..d58aea6 --- /dev/null +++ b/data/raw/liver_profile.csv @@ -0,0 +1,5 @@ +concept_id,allowed,per_person,min,max +3006140,T,1,0, +3035995,T,1,0, +3005755,T,1,0, +3024561,T,1,0, diff --git a/data/raw/monoclonal_bands.csv b/data/raw/monoclonal_bands.csv new file mode 100644 index 0000000..888ed45 --- /dev/null +++ b/data/raw/monoclonal_bands.csv @@ -0,0 +1,5 @@ +concept_id,allowed,per_person,min,max +3029713,T,1,, +3035797,T,0,, +3029338,T,0,, +3029379,T,0,, \ No newline at end of file diff --git a/data/raw/plasma_viscosity.csv b/data/raw/plasma_viscosity.csv new file mode 100644 index 0000000..3d0c136 --- /dev/null +++ b/data/raw/plasma_viscosity.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3024316,T,1,0, + diff --git a/data/raw/renal_profile.csv b/data/raw/renal_profile.csv new file mode 100644 index 0000000..5e736dd --- /dev/null +++ b/data/raw/renal_profile.csv @@ -0,0 +1,5 @@ +concept_id,allowed,per_person,min,max +3019550,T,1,0, +3023103,T,1,0, +3009508,T,1,0, +46236952,T,1,0, diff --git a/data/raw/serum_albumin.csv b/data/raw/serum_albumin.csv new file mode 100644 index 0000000..dfa18ce --- /dev/null +++ b/data/raw/serum_albumin.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3024561,T,1,0, + diff --git a/data/raw/serum_beta_2_microglobulin.csv b/data/raw/serum_beta_2_microglobulin.csv new file mode 100644 index 0000000..adc9694 --- /dev/null +++ b/data/raw/serum_beta_2_microglobulin.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3025890,T,1,0, + diff --git a/data/raw/serum_corrected_calcium.csv b/data/raw/serum_corrected_calcium.csv new file mode 100644 index 0000000..2aecc1d --- /dev/null +++ b/data/raw/serum_corrected_calcium.csv @@ -0,0 +1,2 @@ +concept_id,allowed,per_person,min,max +3020059,T,1,0, diff --git a/data/raw/serum_creatinine.csv b/data/raw/serum_creatinine.csv new file mode 100644 index 0000000..26f08fe --- /dev/null +++ b/data/raw/serum_creatinine.csv @@ -0,0 +1,2 @@ +concept_id,allowed,per_person,min,max +3020564,T,1,0, diff --git a/data/raw/serum_glucose.csv b/data/raw/serum_glucose.csv new file mode 100644 index 0000000..01e4585 --- /dev/null +++ b/data/raw/serum_glucose.csv @@ -0,0 +1,2 @@ +concept_id,allowed,per_person,min,max +3013826,T,1,0, diff --git a/data/raw/serum_immunofixation.csv b/data/raw/serum_immunofixation.csv new file mode 100644 index 0000000..518d166 --- /dev/null +++ b/data/raw/serum_immunofixation.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3034212,F,1,, + diff --git a/data/raw/serum_urea.csv b/data/raw/serum_urea.csv new file mode 100644 index 0000000..0503ea8 --- /dev/null +++ b/data/raw/serum_urea.csv @@ -0,0 +1,2 @@ +concept_id,allowed,per_person,min,max +3020779,T,1,0,, \ No newline at end of file diff --git a/data/raw/smoking.csv b/data/raw/smoking.csv new file mode 100644 index 0000000..2a894cd --- /dev/null +++ b/data/raw/smoking.csv @@ -0,0 +1,7 @@ +concept_id,allowed,per_person,min,max +4092281,T,0,, +4222303,T,0,, +4275495,T,0,, +4276526,T,0,, +4298794,T,0,, +4310250,T,0,, \ No newline at end of file diff --git a/data/raw/snomed_race.csv b/data/raw/snomed_race.csv new file mode 100644 index 0000000..612c04e --- /dev/null +++ b/data/raw/snomed_race.csv @@ -0,0 +1,19 @@ +concept_id,allowed +37394011,T +46285821,T +46286810,T +46285824,T +46285826,T +46285827,T +46285828,T +46285829,T +46285830,T +46285831,T +46285832,T +46285833,T +46285834,T +46285835,T +46286811,T +46285836,T +46285837,T +46285839,T \ No newline at end of file diff --git a/data/raw/thyroid_profile.csv b/data/raw/thyroid_profile.csv new file mode 100644 index 0000000..eca5094 --- /dev/null +++ b/data/raw/thyroid_profile.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3009201,T,1,0, +3008486,T,1,0, \ No newline at end of file diff --git a/data/raw/total_protein.csv b/data/raw/total_protein.csv new file mode 100644 index 0000000..d052ee4 --- /dev/null +++ b/data/raw/total_protein.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3020630,T,1,0, + diff --git a/data/raw/urea_electrolyte.csv b/data/raw/urea_electrolyte.csv new file mode 100644 index 0000000..46ef91c --- /dev/null +++ b/data/raw/urea_electrolyte.csv @@ -0,0 +1,6 @@ +concept_id,allowed,per_person,min,max +3019550,T,1,0, +3023103,T,1,0, +3020779,T,1,0, +3009508,T,1,0, +46236952,T,1,0, diff --git a/data/raw/urine_albumin.csv b/data/raw/urine_albumin.csv new file mode 100644 index 0000000..1d80e2b --- /dev/null +++ b/data/raw/urine_albumin.csv @@ -0,0 +1,3 @@ +concept_id,allowed,per_person,min,max +3000034,T,1,0, + diff --git a/data/raw/urine_bence_jones_protein.csv b/data/raw/urine_bence_jones_protein.csv new file mode 100644 index 0000000..c666be3 --- /dev/null +++ b/data/raw/urine_bence_jones_protein.csv @@ -0,0 +1,8 @@ +concept_id,allowed,per_person,min,max +3009508,T,1,0, +3037121,T,1,0, +3038404,T,1,0, +3020952,T,1,0, +3036677,T,1,0, +3032480,T,1,0, +3042702,T,1,0, \ No newline at end of file From 12bed38ff07aa6887e710853ded06669eb95f139 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 17:12:48 +0100 Subject: [PATCH 03/21] Add minimal functionality for bundle usage --- DESCRIPTION | 19 +- R/bundles.R | 49 +++ R/hello.R | 18 - .../data/raw/measurement}/HBA1c.csv | 0 .../raw => inst/data/raw/measurement}/LDH.csv | 0 .../raw/measurement}/antibodies_to_hiv.csv | 0 .../data/raw/measurement}/antigens.csv | 0 .../raw/measurement}/blood_antibodies.csv | 0 .../data/raw/measurement}/bone_profile.csv | 0 .../measurement}/covid_antibody_levels.csv | 0 .../data/raw/measurement}/eGFR.csv | 0 .../full_blood_count_differential.csv | 0 .../data/raw/measurement}/haemoglobin.csv | 0 .../data/raw/measurement}/haptoglobin.csv | 0 .../raw/measurement}/height_and_weight.csv | 0 .../measurement}/hepatitis_b_screening.csv | 0 .../measurement}/hepatitis_c_screening.csv | 0 .../measurement}/immunofixation_chains.csv | 0 .../data/raw/measurement}/immunoglobulins.csv | 0 .../data/raw/measurement}/light_chains.csv | 0 .../raw/measurement}/liver_function_test.csv | 0 .../data/raw/measurement}/liver_profile.csv | 0 .../raw/measurement}/monoclonal_bands.csv | 0 .../raw/measurement}/plasma_viscosity.csv | 0 .../data/raw/measurement}/renal_profile.csv | 0 .../data/raw/measurement}/serum_albumin.csv | 0 .../serum_beta_2_microglobulin.csv | 0 .../measurement}/serum_corrected_calcium.csv | 0 .../raw/measurement}/serum_creatinine.csv | 0 .../data/raw/measurement}/serum_glucose.csv | 0 .../raw/measurement}/serum_immunofixation.csv | 0 .../data/raw/measurement}/serum_urea.csv | 0 .../data/raw/measurement}/thyroid_profile.csv | 0 .../data/raw/measurement}/total_protein.csv | 0 .../raw/measurement}/urea_electrolyte.csv | 0 .../data/raw/measurement}/urine_albumin.csv | 0 .../urine_bence_jones_protein.csv | 0 .../data/raw/observation}/smoking.csv | 0 .../data/raw/race}/snomed_race.csv | 0 .../raw/unknown}/indices_of_deprivation.csv | 1 - renv.lock | 379 ++++++++++++++++++ tests/testthat.R | 12 + tests/testthat/test-bundles.R | 29 ++ 43 files changed, 482 insertions(+), 25 deletions(-) create mode 100644 R/bundles.R delete mode 100644 R/hello.R rename {data/raw => inst/data/raw/measurement}/HBA1c.csv (100%) rename {data/raw => inst/data/raw/measurement}/LDH.csv (100%) rename {data/raw => inst/data/raw/measurement}/antibodies_to_hiv.csv (100%) rename {data/raw => inst/data/raw/measurement}/antigens.csv (100%) rename {data/raw => inst/data/raw/measurement}/blood_antibodies.csv (100%) rename {data/raw => inst/data/raw/measurement}/bone_profile.csv (100%) rename {data/raw => inst/data/raw/measurement}/covid_antibody_levels.csv (100%) rename {data/raw => inst/data/raw/measurement}/eGFR.csv (100%) rename {data/raw => inst/data/raw/measurement}/full_blood_count_differential.csv (100%) rename {data/raw => inst/data/raw/measurement}/haemoglobin.csv (100%) rename {data/raw => inst/data/raw/measurement}/haptoglobin.csv (100%) rename {data/raw => inst/data/raw/measurement}/height_and_weight.csv (100%) rename {data/raw => inst/data/raw/measurement}/hepatitis_b_screening.csv (100%) rename {data/raw => inst/data/raw/measurement}/hepatitis_c_screening.csv (100%) rename {data/raw => inst/data/raw/measurement}/immunofixation_chains.csv (100%) rename {data/raw => inst/data/raw/measurement}/immunoglobulins.csv (100%) rename {data/raw => inst/data/raw/measurement}/light_chains.csv (100%) rename {data/raw => inst/data/raw/measurement}/liver_function_test.csv (100%) rename {data/raw => inst/data/raw/measurement}/liver_profile.csv (100%) rename {data/raw => inst/data/raw/measurement}/monoclonal_bands.csv (100%) rename {data/raw => inst/data/raw/measurement}/plasma_viscosity.csv (100%) rename {data/raw => inst/data/raw/measurement}/renal_profile.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_albumin.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_beta_2_microglobulin.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_corrected_calcium.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_creatinine.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_glucose.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_immunofixation.csv (100%) rename {data/raw => inst/data/raw/measurement}/serum_urea.csv (100%) rename {data/raw => inst/data/raw/measurement}/thyroid_profile.csv (100%) rename {data/raw => inst/data/raw/measurement}/total_protein.csv (100%) rename {data/raw => inst/data/raw/measurement}/urea_electrolyte.csv (100%) rename {data/raw => inst/data/raw/measurement}/urine_albumin.csv (100%) rename {data/raw => inst/data/raw/measurement}/urine_bence_jones_protein.csv (100%) rename {data/raw => inst/data/raw/observation}/smoking.csv (100%) rename {data/raw => inst/data/raw/race}/snomed_race.csv (100%) rename {data/raw => inst/data/raw/unknown}/indices_of_deprivation.csv (98%) create mode 100644 tests/testthat.R create mode 100644 tests/testthat/test-bundles.R diff --git a/DESCRIPTION b/DESCRIPTION index 99ccac4..b09bdda 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,11 +1,18 @@ Package: omopbundles Type: Package -Title: What the Package Does (Title Case) +Title: Bundles of OMOP Concepts for Ease of Data Selection Version: 0.1.0 -Author: Who wrote it -Maintainer: The package maintainer -Description: More about what it does (maybe more than one line) - Use four spaces when indenting paragraphs within the Description. -License: What license is it under? +Author: person('Stef', 'Piatek', email = 'stefan.piatek@nhs.net', role = c('cre', 'aut')) +Description: Bundles of OMOP Concepts for Ease of Data Selection +License: Apache License (>= 2) Encoding: UTF-8 LazyData: true +Imports: + dplyr (>= 1.0), + purrr (>= 1.0), + readr (>= 2.0) +Suggests: + usethis, + testthat (>= 3.0.0), + lintr +Config/testthat/edition: 3 diff --git a/R/bundles.R b/R/bundles.R new file mode 100644 index 0000000..3ab6c76 --- /dev/null +++ b/R/bundles.R @@ -0,0 +1,49 @@ +#' @importFrom dplyr tibble mutate +#' @importFrom purrr map_dfr +#' @importFrom readr read_csv + +#' Get available bundles for a version +#' +#' If a bundle has multiple names, then the id will be duplicated across rows +#' +#' @param version Requested version, if not defined, the latest will be used +#' @return dataframe that contains a concept_name and a domain column for each available concept +#' @export +available_bundles <- function(version = "latest") { + raw_dir <- .get_raw_dir() + directories <- list.dirs(raw_dir, full.names=TRUE) + domain_directories <- directories[directories != raw_dir] + + purrr::map_dfr(domain_directories, .build_concepts_from_directory) +} + +.get_raw_dir <- function(...) { + system.file("data", "raw", ..., package = "omopbundles", mustWork=TRUE) +} + +.build_concepts_from_directory <- function(directory) { + concept_files <- list.files(directory) + + dplyr::tibble( + id = concept_files, + concept_name = concept_files, + domain = basename(directory) + ) |> + dplyr::mutate(concept_name = sub("\\.csv$", "", concept_name)) |> + dplyr::mutate(concept_name = gsub("_", " ", concept_name)) +} + +#' Get concepts for a a single bundle row +#' +#' +#' @param bundle_row Single row of a dataframe with a domain and id +#' @return Dataframe with a concept_id and domain column +#' @export +concept_by_bundle <- function(bundle_row){ + stopifnot(is.data.frame(bundle_row)) + stopifnot(nrow(bundle_row) == 1) + + .get_raw_dir(bundle_row$domain, bundle_row$id) |> + readr::read_csv(show_col_types = FALSE) |> + dplyr::mutate(domain = bundle_row$domain) +} diff --git a/R/hello.R b/R/hello.R deleted file mode 100644 index 3d348f2..0000000 --- a/R/hello.R +++ /dev/null @@ -1,18 +0,0 @@ -# Hello, world! -# -# This is an example function named 'hello' -# which prints 'Hello, world!'. -# -# You can learn more about package authoring with RStudio at: -# -# http://r-pkgs.had.co.nz/ -# -# Some useful keyboard shortcuts for package authoring: -# -# Install Package: 'Cmd + Shift + B' -# Check Package: 'Cmd + Shift + E' -# Test Package: 'Cmd + Shift + T' - -hello <- function() { - print("Hello, world!") -} diff --git a/data/raw/HBA1c.csv b/inst/data/raw/measurement/HBA1c.csv similarity index 100% rename from data/raw/HBA1c.csv rename to inst/data/raw/measurement/HBA1c.csv diff --git a/data/raw/LDH.csv b/inst/data/raw/measurement/LDH.csv similarity index 100% rename from data/raw/LDH.csv rename to inst/data/raw/measurement/LDH.csv diff --git a/data/raw/antibodies_to_hiv.csv b/inst/data/raw/measurement/antibodies_to_hiv.csv similarity index 100% rename from data/raw/antibodies_to_hiv.csv rename to inst/data/raw/measurement/antibodies_to_hiv.csv diff --git a/data/raw/antigens.csv b/inst/data/raw/measurement/antigens.csv similarity index 100% rename from data/raw/antigens.csv rename to inst/data/raw/measurement/antigens.csv diff --git a/data/raw/blood_antibodies.csv b/inst/data/raw/measurement/blood_antibodies.csv similarity index 100% rename from data/raw/blood_antibodies.csv rename to inst/data/raw/measurement/blood_antibodies.csv diff --git a/data/raw/bone_profile.csv b/inst/data/raw/measurement/bone_profile.csv similarity index 100% rename from data/raw/bone_profile.csv rename to inst/data/raw/measurement/bone_profile.csv diff --git a/data/raw/covid_antibody_levels.csv b/inst/data/raw/measurement/covid_antibody_levels.csv similarity index 100% rename from data/raw/covid_antibody_levels.csv rename to inst/data/raw/measurement/covid_antibody_levels.csv diff --git a/data/raw/eGFR.csv b/inst/data/raw/measurement/eGFR.csv similarity index 100% rename from data/raw/eGFR.csv rename to inst/data/raw/measurement/eGFR.csv diff --git a/data/raw/full_blood_count_differential.csv b/inst/data/raw/measurement/full_blood_count_differential.csv similarity index 100% rename from data/raw/full_blood_count_differential.csv rename to inst/data/raw/measurement/full_blood_count_differential.csv diff --git a/data/raw/haemoglobin.csv b/inst/data/raw/measurement/haemoglobin.csv similarity index 100% rename from data/raw/haemoglobin.csv rename to inst/data/raw/measurement/haemoglobin.csv diff --git a/data/raw/haptoglobin.csv b/inst/data/raw/measurement/haptoglobin.csv similarity index 100% rename from data/raw/haptoglobin.csv rename to inst/data/raw/measurement/haptoglobin.csv diff --git a/data/raw/height_and_weight.csv b/inst/data/raw/measurement/height_and_weight.csv similarity index 100% rename from data/raw/height_and_weight.csv rename to inst/data/raw/measurement/height_and_weight.csv diff --git a/data/raw/hepatitis_b_screening.csv b/inst/data/raw/measurement/hepatitis_b_screening.csv similarity index 100% rename from data/raw/hepatitis_b_screening.csv rename to inst/data/raw/measurement/hepatitis_b_screening.csv diff --git a/data/raw/hepatitis_c_screening.csv b/inst/data/raw/measurement/hepatitis_c_screening.csv similarity index 100% rename from data/raw/hepatitis_c_screening.csv rename to inst/data/raw/measurement/hepatitis_c_screening.csv diff --git a/data/raw/immunofixation_chains.csv b/inst/data/raw/measurement/immunofixation_chains.csv similarity index 100% rename from data/raw/immunofixation_chains.csv rename to inst/data/raw/measurement/immunofixation_chains.csv diff --git a/data/raw/immunoglobulins.csv b/inst/data/raw/measurement/immunoglobulins.csv similarity index 100% rename from data/raw/immunoglobulins.csv rename to inst/data/raw/measurement/immunoglobulins.csv diff --git a/data/raw/light_chains.csv b/inst/data/raw/measurement/light_chains.csv similarity index 100% rename from data/raw/light_chains.csv rename to inst/data/raw/measurement/light_chains.csv diff --git a/data/raw/liver_function_test.csv b/inst/data/raw/measurement/liver_function_test.csv similarity index 100% rename from data/raw/liver_function_test.csv rename to inst/data/raw/measurement/liver_function_test.csv diff --git a/data/raw/liver_profile.csv b/inst/data/raw/measurement/liver_profile.csv similarity index 100% rename from data/raw/liver_profile.csv rename to inst/data/raw/measurement/liver_profile.csv diff --git a/data/raw/monoclonal_bands.csv b/inst/data/raw/measurement/monoclonal_bands.csv similarity index 100% rename from data/raw/monoclonal_bands.csv rename to inst/data/raw/measurement/monoclonal_bands.csv diff --git a/data/raw/plasma_viscosity.csv b/inst/data/raw/measurement/plasma_viscosity.csv similarity index 100% rename from data/raw/plasma_viscosity.csv rename to inst/data/raw/measurement/plasma_viscosity.csv diff --git a/data/raw/renal_profile.csv b/inst/data/raw/measurement/renal_profile.csv similarity index 100% rename from data/raw/renal_profile.csv rename to inst/data/raw/measurement/renal_profile.csv diff --git a/data/raw/serum_albumin.csv b/inst/data/raw/measurement/serum_albumin.csv similarity index 100% rename from data/raw/serum_albumin.csv rename to inst/data/raw/measurement/serum_albumin.csv diff --git a/data/raw/serum_beta_2_microglobulin.csv b/inst/data/raw/measurement/serum_beta_2_microglobulin.csv similarity index 100% rename from data/raw/serum_beta_2_microglobulin.csv rename to inst/data/raw/measurement/serum_beta_2_microglobulin.csv diff --git a/data/raw/serum_corrected_calcium.csv b/inst/data/raw/measurement/serum_corrected_calcium.csv similarity index 100% rename from data/raw/serum_corrected_calcium.csv rename to inst/data/raw/measurement/serum_corrected_calcium.csv diff --git a/data/raw/serum_creatinine.csv b/inst/data/raw/measurement/serum_creatinine.csv similarity index 100% rename from data/raw/serum_creatinine.csv rename to inst/data/raw/measurement/serum_creatinine.csv diff --git a/data/raw/serum_glucose.csv b/inst/data/raw/measurement/serum_glucose.csv similarity index 100% rename from data/raw/serum_glucose.csv rename to inst/data/raw/measurement/serum_glucose.csv diff --git a/data/raw/serum_immunofixation.csv b/inst/data/raw/measurement/serum_immunofixation.csv similarity index 100% rename from data/raw/serum_immunofixation.csv rename to inst/data/raw/measurement/serum_immunofixation.csv diff --git a/data/raw/serum_urea.csv b/inst/data/raw/measurement/serum_urea.csv similarity index 100% rename from data/raw/serum_urea.csv rename to inst/data/raw/measurement/serum_urea.csv diff --git a/data/raw/thyroid_profile.csv b/inst/data/raw/measurement/thyroid_profile.csv similarity index 100% rename from data/raw/thyroid_profile.csv rename to inst/data/raw/measurement/thyroid_profile.csv diff --git a/data/raw/total_protein.csv b/inst/data/raw/measurement/total_protein.csv similarity index 100% rename from data/raw/total_protein.csv rename to inst/data/raw/measurement/total_protein.csv diff --git a/data/raw/urea_electrolyte.csv b/inst/data/raw/measurement/urea_electrolyte.csv similarity index 100% rename from data/raw/urea_electrolyte.csv rename to inst/data/raw/measurement/urea_electrolyte.csv diff --git a/data/raw/urine_albumin.csv b/inst/data/raw/measurement/urine_albumin.csv similarity index 100% rename from data/raw/urine_albumin.csv rename to inst/data/raw/measurement/urine_albumin.csv diff --git a/data/raw/urine_bence_jones_protein.csv b/inst/data/raw/measurement/urine_bence_jones_protein.csv similarity index 100% rename from data/raw/urine_bence_jones_protein.csv rename to inst/data/raw/measurement/urine_bence_jones_protein.csv diff --git a/data/raw/smoking.csv b/inst/data/raw/observation/smoking.csv similarity index 100% rename from data/raw/smoking.csv rename to inst/data/raw/observation/smoking.csv diff --git a/data/raw/snomed_race.csv b/inst/data/raw/race/snomed_race.csv similarity index 100% rename from data/raw/snomed_race.csv rename to inst/data/raw/race/snomed_race.csv diff --git a/data/raw/indices_of_deprivation.csv b/inst/data/raw/unknown/indices_of_deprivation.csv similarity index 98% rename from data/raw/indices_of_deprivation.csv rename to inst/data/raw/unknown/indices_of_deprivation.csv index f93049f..2e674e1 100644 --- a/data/raw/indices_of_deprivation.csv +++ b/inst/data/raw/unknown/indices_of_deprivation.csv @@ -1,3 +1,2 @@ concept_id,allowed,per_person,min,max 35812882,T,0,0, - diff --git a/renv.lock b/renv.lock index c993a8c..736c71d 100644 --- a/renv.lock +++ b/renv.lock @@ -9,6 +9,266 @@ ] }, "Packages": { + "R6": { + "Package": "R6", + "Version": "2.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "470851b6d5d0ac559e9d01bb352b4021" + }, + "bit": { + "Package": "bit", + "Version": "4.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "d242abec29412ce988848d0294b208fd" + }, + "bit64": { + "Package": "bit64", + "Version": "4.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "bit", + "methods", + "stats", + "utils" + ], + "Hash": "9fe98599ca456d6552421db0d6772d8f" + }, + "cli": { + "Package": "cli", + "Version": "3.6.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "utils" + ], + "Hash": "b21916dd77a27642b447374a5d30ecf3" + }, + "clipr": { + "Package": "clipr", + "Version": "0.8.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "utils" + ], + "Hash": "3f038e5ac7f41d4ac41ce658c85e3042" + }, + "cpp11": { + "Package": "cpp11", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "91570bba75d0c9d3f1040c835cee8fba" + }, + "crayon": { + "Package": "crayon", + "Version": "1.5.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "grDevices", + "methods", + "utils" + ], + "Hash": "859d96e65ef198fd43e82b9628d593ef" + }, + "dplyr": { + "Package": "dplyr", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "cli", + "generics", + "glue", + "lifecycle", + "magrittr", + "methods", + "pillar", + "rlang", + "tibble", + "tidyselect", + "utils", + "vctrs" + ], + "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" + }, + "fansi": { + "Package": "fansi", + "Version": "1.0.6", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "grDevices", + "utils" + ], + "Hash": "962174cf2aeb5b9eea581522286a911f" + }, + "generics": { + "Package": "generics", + "Version": "0.1.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "methods" + ], + "Hash": "15e9634c0fcd294799e9b2e929ed1b86" + }, + "glue": { + "Package": "glue", + "Version": "1.7.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "methods" + ], + "Hash": "e0b3a53876554bd45879e596cdb10a52" + }, + "hms": { + "Package": "hms", + "Version": "1.1.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "lifecycle", + "methods", + "pkgconfig", + "rlang", + "vctrs" + ], + "Hash": "b59377caa7ed00fa41808342002138f9" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "1.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "glue", + "rlang" + ], + "Hash": "b8552d117e1b808b09a832f589b79035" + }, + "magrittr": { + "Package": "magrittr", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "7ce2733a9826b3aeb1775d56fd305472" + }, + "pillar": { + "Package": "pillar", + "Version": "1.9.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "cli", + "fansi", + "glue", + "lifecycle", + "rlang", + "utf8", + "utils", + "vctrs" + ], + "Hash": "15da5a8412f317beeee6175fbc76f4bb" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "utils" + ], + "Hash": "01f28d4278f15c76cddbea05899c5d6f" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "6b01fc98b1e86c4f705ce9dcfd2f57c7" + }, + "progress": { + "Package": "progress", + "Version": "1.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "crayon", + "hms", + "prettyunits" + ], + "Hash": "f4625e061cb2865f111b47ff163a5ca6" + }, + "purrr": { + "Package": "purrr", + "Version": "1.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "lifecycle", + "magrittr", + "rlang", + "vctrs" + ], + "Hash": "1cba04a4e9414bdefc9dcaa99649a8dc" + }, + "readr": { + "Package": "readr", + "Version": "2.1.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "cli", + "clipr", + "cpp11", + "crayon", + "hms", + "lifecycle", + "methods", + "rlang", + "tibble", + "tzdb", + "utils", + "vroom" + ], + "Hash": "9de96463d2117f6ac49980577939dfb3" + }, "renv": { "Package": "renv", "Version": "1.0.7", @@ -18,6 +278,125 @@ "utils" ], "Hash": "397b7b2a265bc5a7a06852524dabae20" + }, + "rlang": { + "Package": "rlang", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "utils" + ], + "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" + }, + "tibble": { + "Package": "tibble", + "Version": "3.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "fansi", + "lifecycle", + "magrittr", + "methods", + "pillar", + "pkgconfig", + "rlang", + "utils", + "vctrs" + ], + "Hash": "a84e2cc86d07289b3b6f5069df7a004c" + }, + "tidyselect": { + "Package": "tidyselect", + "Version": "1.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "glue", + "lifecycle", + "rlang", + "vctrs", + "withr" + ], + "Hash": "829f27b9c4919c16b593794a6344d6c0" + }, + "tzdb": { + "Package": "tzdb", + "Version": "0.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cpp11" + ], + "Hash": "f561504ec2897f4d46f0c7657e488ae1" + }, + "utf8": { + "Package": "utf8", + "Version": "1.2.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "62b65c52671e6665f803ff02954446e9" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.6.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "glue", + "lifecycle", + "rlang" + ], + "Hash": "c03fa420630029418f7e6da3667aac4a" + }, + "vroom": { + "Package": "vroom", + "Version": "1.6.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "bit64", + "cli", + "cpp11", + "crayon", + "glue", + "hms", + "lifecycle", + "methods", + "progress", + "rlang", + "stats", + "tibble", + "tidyselect", + "tzdb", + "vctrs", + "withr" + ], + "Hash": "390f9315bc0025be03012054103d227c" + }, + "withr": { + "Package": "withr", + "Version": "3.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "grDevices", + "graphics" + ], + "Hash": "07909200e8bbe90426fbfeb73e1e27aa" } } } diff --git a/tests/testthat.R b/tests/testthat.R new file mode 100644 index 0000000..4b42d00 --- /dev/null +++ b/tests/testthat.R @@ -0,0 +1,12 @@ +# This file is part of the standard setup for testthat. +# It is recommended that you do not modify it. +# +# Where should you do additional test configuration? +# Learn more about the roles of various files in: +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html + +library(testthat) +library(omopbundles) + +test_check("omopbundles") diff --git a/tests/testthat/test-bundles.R b/tests/testthat/test-bundles.R new file mode 100644 index 0000000..32067a9 --- /dev/null +++ b/tests/testthat/test-bundles.R @@ -0,0 +1,29 @@ +library(dplyr) +library(omopbundles) +library(testthat) + + +test_that("available_bundles is not empty",{ + result <- available_bundles() + expect_true(nrow(result) > 0, info = "The dataframe should not be empty") +}) + +test_that("Smoking exists as an observation",{ + result <- available_bundles() |> + dplyr::filter(concept_name == "smoking") + + expect_true(nrow(result) == 1, info = "Smoking should only exist as a single row") + expect_equal(result$domain, "observation") +}) + + +test_that("Avilable bundles and concept_by_bundle play nicely together",{ + smoking_bundle <- available_bundles() |> + dplyr::filter(concept_name == "smoking") + + smoking_concepts <- concept_by_bundle(smoking_bundle) + + expect_true(nrow(smoking_concepts) > 1, info = "Smoking should have multiple concepts") + expect_false(any(is.na(smoking_concepts$concept_id)), info = "Concept ids should not be NA") + expect_true(all(smoking_concepts$domain == "observation"), info = "Domain should be set correctly") +}) From 45eb59316e4618d31ee1dfb5e1f2839904891c46 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 17:56:34 +0100 Subject: [PATCH 04/21] Add in CI checks --- .github/R-CMD-check.yaml | 35 ++++++++++++++++ .github/lint.yaml | 37 +++++++++++++++++ .github/pr-commands.yaml | 86 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 158 insertions(+) create mode 100644 .github/R-CMD-check.yaml create mode 100644 .github/lint.yaml create mode 100644 .github/pr-commands.yaml diff --git a/.github/R-CMD-check.yaml b/.github/R-CMD-check.yaml new file mode 100644 index 0000000..0340f9a --- /dev/null +++ b/.github/R-CMD-check.yaml @@ -0,0 +1,35 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: R-CMD-check.yaml + +permissions: read-all + +jobs: + R-CMD-check: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-renv@v2 + + - name: Install rcmdcheck + run: install.packages("rcmdcheck") + shell: Rscript {0} + + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' diff --git a/.github/lint.yaml b/.github/lint.yaml new file mode 100644 index 0000000..604cc64 --- /dev/null +++ b/.github/lint.yaml @@ -0,0 +1,37 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +name: lint.yaml + +permissions: read-all + +jobs: + lint: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-renv@v2 + + - name: Install lintr + run: install.packages("lintr") + shell: Rscript {0} + + - name: Lint + run: | + pkgload::load_all() + lintr::lint_package() + shell: Rscript {0} + env: + LINTR_ERROR_ON_LINT: true diff --git a/.github/pr-commands.yaml b/.github/pr-commands.yaml new file mode 100644 index 0000000..a8cda62 --- /dev/null +++ b/.github/pr-commands.yaml @@ -0,0 +1,86 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help +on: + issue_comment: + types: [created] + +name: pr-commands.yaml + +permissions: read-all + +jobs: + document: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} + name: document + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-renv@v2 + + - name: Install roxygen2 + run: install.packages("roxygen2") + shell: Rscript {0} + + - name: Document + run: roxygen2::roxygenise() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add man/\* NAMESPACE + git commit -m 'Document' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + style: + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} + name: style + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/pr-fetch@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - uses: r-lib/actions/setup-r@v2 + + - name: Install dependencies + run: install.packages("styler") + shell: Rscript {0} + + - name: Style + run: styler::style_pkg() + shell: Rscript {0} + + - name: commit + run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" + git add \*.R + git commit -m 'Style' + + - uses: r-lib/actions/pr-push@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} From a522ace86991ade06a39e6013860f63bc74a486e Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 17:58:38 +0100 Subject: [PATCH 05/21] Add in CI checks --- .github/{ => workflows}/R-CMD-check.yaml | 0 .github/{ => workflows}/lint.yaml | 0 .github/{ => workflows}/pr-commands.yaml | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/R-CMD-check.yaml (100%) rename .github/{ => workflows}/lint.yaml (100%) rename .github/{ => workflows}/pr-commands.yaml (100%) diff --git a/.github/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml similarity index 100% rename from .github/R-CMD-check.yaml rename to .github/workflows/R-CMD-check.yaml diff --git a/.github/lint.yaml b/.github/workflows/lint.yaml similarity index 100% rename from .github/lint.yaml rename to .github/workflows/lint.yaml diff --git a/.github/pr-commands.yaml b/.github/workflows/pr-commands.yaml similarity index 100% rename from .github/pr-commands.yaml rename to .github/workflows/pr-commands.yaml From 877162c4255fdcb53a44d8575e272687a0f19bae Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 18:22:07 +0100 Subject: [PATCH 06/21] Work on fixing CI --- .lintr | 5 +++++ DESCRIPTION | 6 ++++-- NAMESPACE | 9 ++++++++- R/bundles.R | 7 ++++--- man/concept_by_bundle.Rd | 17 +++++++++++++++++ man/hello.Rd | 12 ------------ renv.lock | 15 +++++++++++++++ tests/testthat/test-bundles.R | 6 +++--- 8 files changed, 56 insertions(+), 21 deletions(-) create mode 100644 .lintr create mode 100644 man/concept_by_bundle.Rd delete mode 100644 man/hello.Rd diff --git a/.lintr b/.lintr new file mode 100644 index 0000000..ba8f1a3 --- /dev/null +++ b/.lintr @@ -0,0 +1,5 @@ +linters: linters_with_defaults( + line_length_linter(120), + object_name_linter(styles = c("snake_case", "symbols", "camelCase")) + ) +encoding: "UTF-8" diff --git a/DESCRIPTION b/DESCRIPTION index b09bdda..07e96d5 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: omopbundles Type: Package Title: Bundles of OMOP Concepts for Ease of Data Selection Version: 0.1.0 -Author: person('Stef', 'Piatek', email = 'stefan.piatek@nhs.net', role = c('cre', 'aut')) +Authors@R: person('Stef', 'Piatek', email = 'stefan.piatek@nhs.net', role = c('cre', 'aut')) Description: Bundles of OMOP Concepts for Ease of Data Selection License: Apache License (>= 2) Encoding: UTF-8 @@ -14,5 +14,7 @@ Imports: Suggests: usethis, testthat (>= 3.0.0), - lintr + lintr, + pkgload Config/testthat/edition: 3 +RoxygenNote: 7.3.2 diff --git a/NAMESPACE b/NAMESPACE index d75f824..a59cf47 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1 +1,8 @@ -exportPattern("^[[:alpha:]]+") +# Generated by roxygen2: do not edit by hand + +export(available_bundles) +export(concept_by_bundle) +importFrom(dplyr,mutate) +importFrom(dplyr,tibble) +importFrom(purrr,map_dfr) +importFrom(readr,read_csv) diff --git a/R/bundles.R b/R/bundles.R index 3ab6c76..9251f52 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -11,18 +11,19 @@ #' @export available_bundles <- function(version = "latest") { raw_dir <- .get_raw_dir() - directories <- list.dirs(raw_dir, full.names=TRUE) + directories <- list.dirs(raw_dir, full.names = TRUE) domain_directories <- directories[directories != raw_dir] purrr::map_dfr(domain_directories, .build_concepts_from_directory) } .get_raw_dir <- function(...) { - system.file("data", "raw", ..., package = "omopbundles", mustWork=TRUE) + system.file("data", "raw", ..., package = "omopbundles", mustWork = TRUE) } .build_concepts_from_directory <- function(directory) { concept_files <- list.files(directory) + concept_name <- NULL dplyr::tibble( id = concept_files, @@ -39,7 +40,7 @@ available_bundles <- function(version = "latest") { #' @param bundle_row Single row of a dataframe with a domain and id #' @return Dataframe with a concept_id and domain column #' @export -concept_by_bundle <- function(bundle_row){ +concept_by_bundle <- function(bundle_row) { stopifnot(is.data.frame(bundle_row)) stopifnot(nrow(bundle_row) == 1) diff --git a/man/concept_by_bundle.Rd b/man/concept_by_bundle.Rd new file mode 100644 index 0000000..bd11479 --- /dev/null +++ b/man/concept_by_bundle.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bundles.R +\name{concept_by_bundle} +\alias{concept_by_bundle} +\title{Get concepts for a a single bundle row} +\usage{ +concept_by_bundle(bundle_row) +} +\arguments{ +\item{bundle_row}{Single row of a dataframe with a domain and id} +} +\value{ +Dataframe with a concept_id and domain column +} +\description{ +Get concepts for a a single bundle row +} diff --git a/man/hello.Rd b/man/hello.Rd deleted file mode 100644 index 0fa7c4b..0000000 --- a/man/hello.Rd +++ /dev/null @@ -1,12 +0,0 @@ -\name{hello} -\alias{hello} -\title{Hello, World!} -\usage{ -hello() -} -\description{ -Prints 'Hello, world!'. -} -\examples{ -hello() -} diff --git a/renv.lock b/renv.lock index 736c71d..79dc60c 100644 --- a/renv.lock +++ b/renv.lock @@ -170,6 +170,11 @@ ], "Hash": "b8552d117e1b808b09a832f589b79035" }, + "lintr": { + "Package": "lintr", + "Version": "3.1.2", + "Source": "Repository" + }, "magrittr": { "Package": "magrittr", "Version": "2.0.3", @@ -207,6 +212,11 @@ ], "Hash": "01f28d4278f15c76cddbea05899c5d6f" }, + "pkgload": { + "Package": "pkgload", + "Version": "1.4.0", + "Source": "Repository" + }, "prettyunits": { "Package": "prettyunits", "Version": "1.2.0", @@ -290,6 +300,11 @@ ], "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, + "roxygen2": { + "Package": "roxygen2", + "Version": "7.3.2", + "Source": "Repository" + }, "tibble": { "Package": "tibble", "Version": "3.2.1", diff --git a/tests/testthat/test-bundles.R b/tests/testthat/test-bundles.R index 32067a9..5c4ba2e 100644 --- a/tests/testthat/test-bundles.R +++ b/tests/testthat/test-bundles.R @@ -3,12 +3,12 @@ library(omopbundles) library(testthat) -test_that("available_bundles is not empty",{ +test_that("available_bundles is not empty", { result <- available_bundles() expect_true(nrow(result) > 0, info = "The dataframe should not be empty") }) -test_that("Smoking exists as an observation",{ +test_that("Smoking exists as an observation", { result <- available_bundles() |> dplyr::filter(concept_name == "smoking") @@ -17,7 +17,7 @@ test_that("Smoking exists as an observation",{ }) -test_that("Avilable bundles and concept_by_bundle play nicely together",{ +test_that("Avilable bundles and concept_by_bundle play nicely together", { smoking_bundle <- available_bundles() |> dplyr::filter(concept_name == "smoking") From 0898a92a87c15670c3ed1631d7c5278c6e509b90 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 18:52:41 +0100 Subject: [PATCH 07/21] Update documentation --- R/bundles.R | 10 ++++++---- man/available_bundles.Rd | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 man/available_bundles.Rd diff --git a/R/bundles.R b/R/bundles.R index 9251f52..8ac2254 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -2,13 +2,16 @@ #' @importFrom purrr map_dfr #' @importFrom readr read_csv -#' Get available bundles for a version +#' @title Get available bundles for a version #' -#' If a bundle has multiple names, then the id will be duplicated across rows +#' @description If a bundle has multiple names, then the id will be duplicated across rows #' #' @param version Requested version, if not defined, the latest will be used #' @return dataframe that contains a concept_name and a domain column for each available concept #' @export +#' @examples +#' available_bundles() +#' available_bundles('0.1') available_bundles <- function(version = "latest") { raw_dir <- .get_raw_dir() directories <- list.dirs(raw_dir, full.names = TRUE) @@ -34,8 +37,7 @@ available_bundles <- function(version = "latest") { dplyr::mutate(concept_name = gsub("_", " ", concept_name)) } -#' Get concepts for a a single bundle row -#' +#' @title Get concepts for a a single bundle row #' #' @param bundle_row Single row of a dataframe with a domain and id #' @return Dataframe with a concept_id and domain column diff --git a/man/available_bundles.Rd b/man/available_bundles.Rd new file mode 100644 index 0000000..8cc7da7 --- /dev/null +++ b/man/available_bundles.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/bundles.R +\name{available_bundles} +\alias{available_bundles} +\title{Get available bundles for a version} +\usage{ +available_bundles(version = "latest") +} +\arguments{ +\item{version}{Requested version, if not defined, the latest will be used} +} +\value{ +dataframe that contains a concept_name and a domain column for each available concept +} +\description{ +If a bundle has multiple names, then the id will be duplicated across rows +} +\examples{ +available_bundles() +available_bundles('0.1') +} From 1892acd244df1477677396fabc38b949ce10c632 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 18:56:49 +0100 Subject: [PATCH 08/21] ignore lintr and github --- .Rbuildignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.Rbuildignore b/.Rbuildignore index d821302..44e285c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -2,3 +2,5 @@ ^renv\.lock$ ^.*\.Rproj$ ^\.Rproj\.user$ +^.lintr$ +^.github$ From 320136942b2eb39642be10cea85f7537b987853b Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 19:06:03 +0100 Subject: [PATCH 09/21] Add testthat to renv --- renv.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/renv.lock b/renv.lock index 79dc60c..a4d6ec4 100644 --- a/renv.lock +++ b/renv.lock @@ -305,6 +305,11 @@ "Version": "7.3.2", "Source": "Repository" }, + "testthat": { + "Package": "testthat", + "Version": "3.2.1.1", + "Source": "Repository" + }, "tibble": { "Package": "tibble", "Version": "3.2.1", From 015b45a0f9b014258f88db56f638b4299c8d8f9c Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 19:08:26 +0100 Subject: [PATCH 10/21] add usethis --- renv.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/renv.lock b/renv.lock index a4d6ec4..2b8ca90 100644 --- a/renv.lock +++ b/renv.lock @@ -356,6 +356,11 @@ ], "Hash": "f561504ec2897f4d46f0c7657e488ae1" }, + "usethis": { + "Package": "usethis", + "Version": "3.0.0", + "Source": "Repository" + }, "utf8": { "Package": "utf8", "Version": "1.2.4", From b57c1bf6582d23cece7e7e0bffbb9d00433538b8 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 19:16:47 +0100 Subject: [PATCH 11/21] move raw data --- R/bundles.R | 2 +- inst/{data/raw => data-raw}/measurement/HBA1c.csv | 0 inst/{data/raw => data-raw}/measurement/LDH.csv | 0 inst/{data/raw => data-raw}/measurement/antibodies_to_hiv.csv | 0 inst/{data/raw => data-raw}/measurement/antigens.csv | 0 inst/{data/raw => data-raw}/measurement/blood_antibodies.csv | 0 inst/{data/raw => data-raw}/measurement/bone_profile.csv | 0 .../raw => data-raw}/measurement/covid_antibody_levels.csv | 0 inst/{data/raw => data-raw}/measurement/eGFR.csv | 0 .../measurement/full_blood_count_differential.csv | 0 inst/{data/raw => data-raw}/measurement/haemoglobin.csv | 0 inst/{data/raw => data-raw}/measurement/haptoglobin.csv | 0 inst/{data/raw => data-raw}/measurement/height_and_weight.csv | 0 .../raw => data-raw}/measurement/hepatitis_b_screening.csv | 0 .../raw => data-raw}/measurement/hepatitis_c_screening.csv | 0 .../raw => data-raw}/measurement/immunofixation_chains.csv | 0 inst/{data/raw => data-raw}/measurement/immunoglobulins.csv | 0 inst/{data/raw => data-raw}/measurement/light_chains.csv | 0 inst/{data/raw => data-raw}/measurement/liver_function_test.csv | 0 inst/{data/raw => data-raw}/measurement/liver_profile.csv | 0 inst/{data/raw => data-raw}/measurement/monoclonal_bands.csv | 0 inst/{data/raw => data-raw}/measurement/plasma_viscosity.csv | 0 inst/{data/raw => data-raw}/measurement/renal_profile.csv | 0 inst/{data/raw => data-raw}/measurement/serum_albumin.csv | 0 .../raw => data-raw}/measurement/serum_beta_2_microglobulin.csv | 0 .../raw => data-raw}/measurement/serum_corrected_calcium.csv | 0 inst/{data/raw => data-raw}/measurement/serum_creatinine.csv | 0 inst/{data/raw => data-raw}/measurement/serum_glucose.csv | 0 .../{data/raw => data-raw}/measurement/serum_immunofixation.csv | 0 inst/{data/raw => data-raw}/measurement/serum_urea.csv | 0 inst/{data/raw => data-raw}/measurement/thyroid_profile.csv | 0 inst/{data/raw => data-raw}/measurement/total_protein.csv | 0 inst/{data/raw => data-raw}/measurement/urea_electrolyte.csv | 0 inst/{data/raw => data-raw}/measurement/urine_albumin.csv | 0 .../raw => data-raw}/measurement/urine_bence_jones_protein.csv | 0 inst/{data/raw => data-raw}/observation/smoking.csv | 0 inst/{data/raw => data-raw}/race/snomed_race.csv | 0 inst/{data/raw => data-raw}/unknown/indices_of_deprivation.csv | 0 38 files changed, 1 insertion(+), 1 deletion(-) rename inst/{data/raw => data-raw}/measurement/HBA1c.csv (100%) rename inst/{data/raw => data-raw}/measurement/LDH.csv (100%) rename inst/{data/raw => data-raw}/measurement/antibodies_to_hiv.csv (100%) rename inst/{data/raw => data-raw}/measurement/antigens.csv (100%) rename inst/{data/raw => data-raw}/measurement/blood_antibodies.csv (100%) rename inst/{data/raw => data-raw}/measurement/bone_profile.csv (100%) rename inst/{data/raw => data-raw}/measurement/covid_antibody_levels.csv (100%) rename inst/{data/raw => data-raw}/measurement/eGFR.csv (100%) rename inst/{data/raw => data-raw}/measurement/full_blood_count_differential.csv (100%) rename inst/{data/raw => data-raw}/measurement/haemoglobin.csv (100%) rename inst/{data/raw => data-raw}/measurement/haptoglobin.csv (100%) rename inst/{data/raw => data-raw}/measurement/height_and_weight.csv (100%) rename inst/{data/raw => data-raw}/measurement/hepatitis_b_screening.csv (100%) rename inst/{data/raw => data-raw}/measurement/hepatitis_c_screening.csv (100%) rename inst/{data/raw => data-raw}/measurement/immunofixation_chains.csv (100%) rename inst/{data/raw => data-raw}/measurement/immunoglobulins.csv (100%) rename inst/{data/raw => data-raw}/measurement/light_chains.csv (100%) rename inst/{data/raw => data-raw}/measurement/liver_function_test.csv (100%) rename inst/{data/raw => data-raw}/measurement/liver_profile.csv (100%) rename inst/{data/raw => data-raw}/measurement/monoclonal_bands.csv (100%) rename inst/{data/raw => data-raw}/measurement/plasma_viscosity.csv (100%) rename inst/{data/raw => data-raw}/measurement/renal_profile.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_albumin.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_beta_2_microglobulin.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_corrected_calcium.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_creatinine.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_glucose.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_immunofixation.csv (100%) rename inst/{data/raw => data-raw}/measurement/serum_urea.csv (100%) rename inst/{data/raw => data-raw}/measurement/thyroid_profile.csv (100%) rename inst/{data/raw => data-raw}/measurement/total_protein.csv (100%) rename inst/{data/raw => data-raw}/measurement/urea_electrolyte.csv (100%) rename inst/{data/raw => data-raw}/measurement/urine_albumin.csv (100%) rename inst/{data/raw => data-raw}/measurement/urine_bence_jones_protein.csv (100%) rename inst/{data/raw => data-raw}/observation/smoking.csv (100%) rename inst/{data/raw => data-raw}/race/snomed_race.csv (100%) rename inst/{data/raw => data-raw}/unknown/indices_of_deprivation.csv (100%) diff --git a/R/bundles.R b/R/bundles.R index 8ac2254..1b2bb61 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -21,7 +21,7 @@ available_bundles <- function(version = "latest") { } .get_raw_dir <- function(...) { - system.file("data", "raw", ..., package = "omopbundles", mustWork = TRUE) + system.file("data-raw", ..., package = "omopbundles", mustWork = TRUE) } .build_concepts_from_directory <- function(directory) { diff --git a/inst/data/raw/measurement/HBA1c.csv b/inst/data-raw/measurement/HBA1c.csv similarity index 100% rename from inst/data/raw/measurement/HBA1c.csv rename to inst/data-raw/measurement/HBA1c.csv diff --git a/inst/data/raw/measurement/LDH.csv b/inst/data-raw/measurement/LDH.csv similarity index 100% rename from inst/data/raw/measurement/LDH.csv rename to inst/data-raw/measurement/LDH.csv diff --git a/inst/data/raw/measurement/antibodies_to_hiv.csv b/inst/data-raw/measurement/antibodies_to_hiv.csv similarity index 100% rename from inst/data/raw/measurement/antibodies_to_hiv.csv rename to inst/data-raw/measurement/antibodies_to_hiv.csv diff --git a/inst/data/raw/measurement/antigens.csv b/inst/data-raw/measurement/antigens.csv similarity index 100% rename from inst/data/raw/measurement/antigens.csv rename to inst/data-raw/measurement/antigens.csv diff --git a/inst/data/raw/measurement/blood_antibodies.csv b/inst/data-raw/measurement/blood_antibodies.csv similarity index 100% rename from inst/data/raw/measurement/blood_antibodies.csv rename to inst/data-raw/measurement/blood_antibodies.csv diff --git a/inst/data/raw/measurement/bone_profile.csv b/inst/data-raw/measurement/bone_profile.csv similarity index 100% rename from inst/data/raw/measurement/bone_profile.csv rename to inst/data-raw/measurement/bone_profile.csv diff --git a/inst/data/raw/measurement/covid_antibody_levels.csv b/inst/data-raw/measurement/covid_antibody_levels.csv similarity index 100% rename from inst/data/raw/measurement/covid_antibody_levels.csv rename to inst/data-raw/measurement/covid_antibody_levels.csv diff --git a/inst/data/raw/measurement/eGFR.csv b/inst/data-raw/measurement/eGFR.csv similarity index 100% rename from inst/data/raw/measurement/eGFR.csv rename to inst/data-raw/measurement/eGFR.csv diff --git a/inst/data/raw/measurement/full_blood_count_differential.csv b/inst/data-raw/measurement/full_blood_count_differential.csv similarity index 100% rename from inst/data/raw/measurement/full_blood_count_differential.csv rename to inst/data-raw/measurement/full_blood_count_differential.csv diff --git a/inst/data/raw/measurement/haemoglobin.csv b/inst/data-raw/measurement/haemoglobin.csv similarity index 100% rename from inst/data/raw/measurement/haemoglobin.csv rename to inst/data-raw/measurement/haemoglobin.csv diff --git a/inst/data/raw/measurement/haptoglobin.csv b/inst/data-raw/measurement/haptoglobin.csv similarity index 100% rename from inst/data/raw/measurement/haptoglobin.csv rename to inst/data-raw/measurement/haptoglobin.csv diff --git a/inst/data/raw/measurement/height_and_weight.csv b/inst/data-raw/measurement/height_and_weight.csv similarity index 100% rename from inst/data/raw/measurement/height_and_weight.csv rename to inst/data-raw/measurement/height_and_weight.csv diff --git a/inst/data/raw/measurement/hepatitis_b_screening.csv b/inst/data-raw/measurement/hepatitis_b_screening.csv similarity index 100% rename from inst/data/raw/measurement/hepatitis_b_screening.csv rename to inst/data-raw/measurement/hepatitis_b_screening.csv diff --git a/inst/data/raw/measurement/hepatitis_c_screening.csv b/inst/data-raw/measurement/hepatitis_c_screening.csv similarity index 100% rename from inst/data/raw/measurement/hepatitis_c_screening.csv rename to inst/data-raw/measurement/hepatitis_c_screening.csv diff --git a/inst/data/raw/measurement/immunofixation_chains.csv b/inst/data-raw/measurement/immunofixation_chains.csv similarity index 100% rename from inst/data/raw/measurement/immunofixation_chains.csv rename to inst/data-raw/measurement/immunofixation_chains.csv diff --git a/inst/data/raw/measurement/immunoglobulins.csv b/inst/data-raw/measurement/immunoglobulins.csv similarity index 100% rename from inst/data/raw/measurement/immunoglobulins.csv rename to inst/data-raw/measurement/immunoglobulins.csv diff --git a/inst/data/raw/measurement/light_chains.csv b/inst/data-raw/measurement/light_chains.csv similarity index 100% rename from inst/data/raw/measurement/light_chains.csv rename to inst/data-raw/measurement/light_chains.csv diff --git a/inst/data/raw/measurement/liver_function_test.csv b/inst/data-raw/measurement/liver_function_test.csv similarity index 100% rename from inst/data/raw/measurement/liver_function_test.csv rename to inst/data-raw/measurement/liver_function_test.csv diff --git a/inst/data/raw/measurement/liver_profile.csv b/inst/data-raw/measurement/liver_profile.csv similarity index 100% rename from inst/data/raw/measurement/liver_profile.csv rename to inst/data-raw/measurement/liver_profile.csv diff --git a/inst/data/raw/measurement/monoclonal_bands.csv b/inst/data-raw/measurement/monoclonal_bands.csv similarity index 100% rename from inst/data/raw/measurement/monoclonal_bands.csv rename to inst/data-raw/measurement/monoclonal_bands.csv diff --git a/inst/data/raw/measurement/plasma_viscosity.csv b/inst/data-raw/measurement/plasma_viscosity.csv similarity index 100% rename from inst/data/raw/measurement/plasma_viscosity.csv rename to inst/data-raw/measurement/plasma_viscosity.csv diff --git a/inst/data/raw/measurement/renal_profile.csv b/inst/data-raw/measurement/renal_profile.csv similarity index 100% rename from inst/data/raw/measurement/renal_profile.csv rename to inst/data-raw/measurement/renal_profile.csv diff --git a/inst/data/raw/measurement/serum_albumin.csv b/inst/data-raw/measurement/serum_albumin.csv similarity index 100% rename from inst/data/raw/measurement/serum_albumin.csv rename to inst/data-raw/measurement/serum_albumin.csv diff --git a/inst/data/raw/measurement/serum_beta_2_microglobulin.csv b/inst/data-raw/measurement/serum_beta_2_microglobulin.csv similarity index 100% rename from inst/data/raw/measurement/serum_beta_2_microglobulin.csv rename to inst/data-raw/measurement/serum_beta_2_microglobulin.csv diff --git a/inst/data/raw/measurement/serum_corrected_calcium.csv b/inst/data-raw/measurement/serum_corrected_calcium.csv similarity index 100% rename from inst/data/raw/measurement/serum_corrected_calcium.csv rename to inst/data-raw/measurement/serum_corrected_calcium.csv diff --git a/inst/data/raw/measurement/serum_creatinine.csv b/inst/data-raw/measurement/serum_creatinine.csv similarity index 100% rename from inst/data/raw/measurement/serum_creatinine.csv rename to inst/data-raw/measurement/serum_creatinine.csv diff --git a/inst/data/raw/measurement/serum_glucose.csv b/inst/data-raw/measurement/serum_glucose.csv similarity index 100% rename from inst/data/raw/measurement/serum_glucose.csv rename to inst/data-raw/measurement/serum_glucose.csv diff --git a/inst/data/raw/measurement/serum_immunofixation.csv b/inst/data-raw/measurement/serum_immunofixation.csv similarity index 100% rename from inst/data/raw/measurement/serum_immunofixation.csv rename to inst/data-raw/measurement/serum_immunofixation.csv diff --git a/inst/data/raw/measurement/serum_urea.csv b/inst/data-raw/measurement/serum_urea.csv similarity index 100% rename from inst/data/raw/measurement/serum_urea.csv rename to inst/data-raw/measurement/serum_urea.csv diff --git a/inst/data/raw/measurement/thyroid_profile.csv b/inst/data-raw/measurement/thyroid_profile.csv similarity index 100% rename from inst/data/raw/measurement/thyroid_profile.csv rename to inst/data-raw/measurement/thyroid_profile.csv diff --git a/inst/data/raw/measurement/total_protein.csv b/inst/data-raw/measurement/total_protein.csv similarity index 100% rename from inst/data/raw/measurement/total_protein.csv rename to inst/data-raw/measurement/total_protein.csv diff --git a/inst/data/raw/measurement/urea_electrolyte.csv b/inst/data-raw/measurement/urea_electrolyte.csv similarity index 100% rename from inst/data/raw/measurement/urea_electrolyte.csv rename to inst/data-raw/measurement/urea_electrolyte.csv diff --git a/inst/data/raw/measurement/urine_albumin.csv b/inst/data-raw/measurement/urine_albumin.csv similarity index 100% rename from inst/data/raw/measurement/urine_albumin.csv rename to inst/data-raw/measurement/urine_albumin.csv diff --git a/inst/data/raw/measurement/urine_bence_jones_protein.csv b/inst/data-raw/measurement/urine_bence_jones_protein.csv similarity index 100% rename from inst/data/raw/measurement/urine_bence_jones_protein.csv rename to inst/data-raw/measurement/urine_bence_jones_protein.csv diff --git a/inst/data/raw/observation/smoking.csv b/inst/data-raw/observation/smoking.csv similarity index 100% rename from inst/data/raw/observation/smoking.csv rename to inst/data-raw/observation/smoking.csv diff --git a/inst/data/raw/race/snomed_race.csv b/inst/data-raw/race/snomed_race.csv similarity index 100% rename from inst/data/raw/race/snomed_race.csv rename to inst/data-raw/race/snomed_race.csv diff --git a/inst/data/raw/unknown/indices_of_deprivation.csv b/inst/data-raw/unknown/indices_of_deprivation.csv similarity index 100% rename from inst/data/raw/unknown/indices_of_deprivation.csv rename to inst/data-raw/unknown/indices_of_deprivation.csv From e6d527fcd78f4ed3b510ed4f720c8d9f9a26fcde Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Wed, 28 Aug 2024 19:17:14 +0100 Subject: [PATCH 12/21] Use full sentence in description --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 07e96d5..3e2c89d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -3,7 +3,7 @@ Type: Package Title: Bundles of OMOP Concepts for Ease of Data Selection Version: 0.1.0 Authors@R: person('Stef', 'Piatek', email = 'stefan.piatek@nhs.net', role = c('cre', 'aut')) -Description: Bundles of OMOP Concepts for Ease of Data Selection +Description: Bundles of OMOP Concepts for Ease of Data Selection. License: Apache License (>= 2) Encoding: UTF-8 LazyData: true From 96da9f19d5f9c0d44a95ceb2bea54cbeea253d96 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Thu, 29 Aug 2024 09:36:27 +0100 Subject: [PATCH 13/21] Add readme and add dev to lockfile --- DESCRIPTION | 1 + README.md | 91 ++++++++- renv.lock | 574 +++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 656 insertions(+), 10 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3e2c89d..202ad8a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,6 +15,7 @@ Suggests: usethis, testthat (>= 3.0.0), lintr, + pak, pkgload Config/testthat/edition: 3 RoxygenNote: 7.3.2 diff --git a/README.md b/README.md index 792dd4a..99fc19e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,89 @@ -# omop-bundles -R package to provide access to OMOP bundles +# Omop Bundles + + +[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental) +[![R-CMD-check](https://github.com/SAFEHR-data/omop-bundles/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/SAFEHR-data/omop-bundles/actions/workflows/R-CMD-check.yaml) + + +Catalogue of omop concepts grouped into useful bundles to help researchers select concepts. + +## Overview + +1. [Installation](#installation) +2. [Development](#development) + - [Set up](#set-up) + - [Updating the `renv` lockfile](#updating-the-renv-lockfile) + - [Design](#design) + - [Coding style](#coding-style) +3. [Deployment](./deploy/README.md) + +## Installation + +You can install the development version of data-catalogue from within R: + +```r +# install.packages("pak") +pak::pak("SAFEHR-data/data-catalogue") +``` + +## Development + +### Set up + +Make sure you have a [recent version of R](https://cloud.r-project.org/) (>= 4.4.0) installed. +Though not required, [RStudio](https://www.rstudio.com/products/rstudio/download/) is recommended as an IDE, +as it has good support for R package development and Shiny. + +1. Clone this repository + + - Either with `git clone git@github.com:SAFEHR-data/omop-bundles.git` + - Or by creating [a new project in RStudio from version control](https://docs.posit.co/ide/user/ide/guide/tools/version-control.html#creating-a-new-project-based-on-a-remote-git-or-subversion-repository) + +2. Install [`{renv}`](https://rstudio.github.io/renv/index.html) and restore the project library by running the following from an R console in the project directory: + + ```r + install.packages("renv") + renv::restore() + ``` + +### Updating the `renv` lockfile + +Make sure to regularly run `renv::status(dev = TRUE)` to check if your local library and the lockfile +are up to date. + +When adding a new dependency, install it in the `renv` library with + +```r +renv::install("package_name") +``` + +and then use it in your code as usual. +`renv` will pick up the new package if it's installed and used in the project. + +To update the lockfile, run + +```r +renv::snapshot(dev = TRUE) +``` + +The `dev = TRUE` argument ensures that development dependencies (e.g. those recorded under +`Suggests` in the `DESCRIPTION` file) are also included in the lockfile. + +### Coding style + +We are following the [tidyverse style guide](https://style.tidyverse.org/). +The [`{styler}`](https://styler.r-lib.org/index.html) package can be used to automatically format R code to this style, +by regularly running + +```r +styler::style_pkg() +``` + +within the project directory. +It's also recommended to install [`{lintr}`](https://github.com/r-lib/lintr) and regularly run + +```r +lintr::lint_package() +``` + +(or have it [run automatically in your IDE](https://lintr.r-lib.org/articles/editors.html)). diff --git a/renv.lock b/renv.lock index 2b8ca90..4ddfadb 100644 --- a/renv.lock +++ b/renv.lock @@ -19,6 +19,26 @@ ], "Hash": "470851b6d5d0ac559e9d01bb352b4021" }, + "askpass": { + "Package": "askpass", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "sys" + ], + "Hash": "cad6cf7f1d5f6e906700b9d3e718c796" + }, + "backports": { + "Package": "backports", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "e1e1b9d75c37401117b636b7ae50827a" + }, "bit": { "Package": "bit", "Version": "4.0.5", @@ -43,6 +63,29 @@ ], "Hash": "9fe98599ca456d6552421db0d6772d8f" }, + "brio": { + "Package": "brio", + "Version": "1.1.5", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R" + ], + "Hash": "c1ee497a6d999947c2c224ae46799b1a" + }, + "callr": { + "Package": "callr", + "Version": "3.7.6", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "processx", + "utils" + ], + "Hash": "d7e13f49c19103ece9e58ad2d83a7354" + }, "cli": { "Package": "cli", "Version": "3.6.3", @@ -64,6 +107,16 @@ ], "Hash": "3f038e5ac7f41d4ac41ce658c85e3042" }, + "codetools": { + "Package": "codetools", + "Version": "0.2-20", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "61e097f35917d342622f21cdc79c256e" + }, "cpp11": { "Package": "cpp11", "Version": "0.5.0", @@ -86,6 +139,83 @@ ], "Hash": "859d96e65ef198fd43e82b9628d593ef" }, + "credentials": { + "Package": "credentials", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "askpass", + "curl", + "jsonlite", + "openssl", + "sys" + ], + "Hash": "c7844b32098dcbd1c59cbd8dddb4ecc6" + }, + "curl": { + "Package": "curl", + "Version": "5.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "8f27335f2bcff4d6035edcc82d7d46de" + }, + "cyclocomp": { + "Package": "cyclocomp", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "callr", + "crayon", + "desc", + "remotes", + "withr" + ], + "Hash": "cdc4a473222b0112d4df0bcfbed12d44" + }, + "desc": { + "Package": "desc", + "Version": "1.4.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "cli", + "utils" + ], + "Hash": "99b79fcbd6c4d1ce087f5c5c758b384f" + }, + "diffobj": { + "Package": "diffobj", + "Version": "0.3.5", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "crayon", + "methods", + "stats", + "tools", + "utils" + ], + "Hash": "bcaa8b95f8d7d01a5dedfd959ce88ab8" + }, + "digest": { + "Package": "digest", + "Version": "0.6.37", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "utils" + ], + "Hash": "33698c4b3127fc9f506654607fb73676" + }, "dplyr": { "Package": "dplyr", "Version": "1.1.4", @@ -109,6 +239,17 @@ ], "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" }, + "evaluate": { + "Package": "evaluate", + "Version": "0.24.0", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "methods" + ], + "Hash": "a1066cbc05caee9a4bf6d90f194ff4da" + }, "fansi": { "Package": "fansi", "Version": "1.0.6", @@ -121,6 +262,17 @@ ], "Hash": "962174cf2aeb5b9eea581522286a911f" }, + "fs": { + "Package": "fs", + "Version": "1.6.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "methods" + ], + "Hash": "15aeb8c27f5ea5161f9f6a641fafd93a" + }, "generics": { "Package": "generics", "Version": "0.1.3", @@ -132,6 +284,49 @@ ], "Hash": "15e9634c0fcd294799e9b2e929ed1b86" }, + "gert": { + "Package": "gert", + "Version": "2.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "askpass", + "credentials", + "openssl", + "rstudioapi", + "sys", + "zip" + ], + "Hash": "ab2ca7d6bd706ed218d096b7b16d7233" + }, + "gh": { + "Package": "gh", + "Version": "1.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "gitcreds", + "glue", + "httr2", + "ini", + "jsonlite", + "lifecycle", + "rlang" + ], + "Hash": "fbbbc48eba7a6626a08bb365e44b563b" + }, + "gitcreds": { + "Package": "gitcreds", + "Version": "0.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "ab08ac61f3e1be454ae21911eb8bc2fe" + }, "glue": { "Package": "glue", "Version": "1.7.0", @@ -143,6 +338,17 @@ ], "Hash": "e0b3a53876554bd45879e596cdb10a52" }, + "highr": { + "Package": "highr", + "Version": "0.11", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "xfun" + ], + "Hash": "d65ba49117ca223614f71b60d85b8ab7" + }, "hms": { "Package": "hms", "Version": "1.1.3", @@ -157,6 +363,70 @@ ], "Hash": "b59377caa7ed00fa41808342002138f9" }, + "httr2": { + "Package": "httr2", + "Version": "1.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "cli", + "curl", + "glue", + "lifecycle", + "magrittr", + "openssl", + "rappdirs", + "rlang", + "vctrs", + "withr" + ], + "Hash": "10d93e97faad6b629301bb3a2fd23378" + }, + "ini": { + "Package": "ini", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6154ec2223172bce8162d4153cda21f7" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "1.8.8", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "methods" + ], + "Hash": "e1b9c55281c5adc4dd113652d9e26768" + }, + "knitr": { + "Package": "knitr", + "Version": "1.48", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "evaluate", + "highr", + "methods", + "tools", + "xfun", + "yaml" + ], + "Hash": "acf380f300c721da9fde7df115a5f86f" + }, + "lazyeval": { + "Package": "lazyeval", + "Version": "0.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "d908914ae53b04d4c0c0fd72ecc35370" + }, "lifecycle": { "Package": "lifecycle", "Version": "1.0.4", @@ -173,7 +443,23 @@ "lintr": { "Package": "lintr", "Version": "3.1.2", - "Source": "Repository" + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "backports", + "codetools", + "cyclocomp", + "digest", + "glue", + "knitr", + "rex", + "stats", + "utils", + "xml2", + "xmlparsedata" + ], + "Hash": "08cff46381a242d44c0d8dd0aabd9f71" }, "magrittr": { "Package": "magrittr", @@ -185,6 +471,28 @@ ], "Hash": "7ce2733a9826b3aeb1775d56fd305472" }, + "openssl": { + "Package": "openssl", + "Version": "2.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "askpass" + ], + "Hash": "c62edf62de70cadf40553e10c739049d" + }, + "pak": { + "Package": "pak", + "Version": "0.8.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "tools", + "utils" + ], + "Hash": "019d4d5634410800a96b69737fb2dbac" + }, "pillar": { "Package": "pillar", "Version": "1.9.0", @@ -202,6 +510,21 @@ ], "Hash": "15da5a8412f317beeee6175fbc76f4bb" }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.4.4", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "callr", + "cli", + "desc", + "processx" + ], + "Hash": "a29e8e134a460a01e0ca67a4763c595b" + }, "pkgconfig": { "Package": "pkgconfig", "Version": "2.0.3", @@ -215,7 +538,31 @@ "pkgload": { "Package": "pkgload", "Version": "1.4.0", - "Source": "Repository" + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "desc", + "fs", + "glue", + "lifecycle", + "methods", + "pkgbuild", + "processx", + "rlang", + "rprojroot", + "utils", + "withr" + ], + "Hash": "2ec30ffbeec83da57655b850cf2d3e0e" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "RSPM", + "Hash": "a555924add98c99d2f411e37e7d25e9f" }, "prettyunits": { "Package": "prettyunits", @@ -227,6 +574,19 @@ ], "Hash": "6b01fc98b1e86c4f705ce9dcfd2f57c7" }, + "processx": { + "Package": "processx", + "Version": "3.8.4", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "R6", + "ps", + "utils" + ], + "Hash": "0c90a7d71988856bad2a2a45dd871bb9" + }, "progress": { "Package": "progress", "Version": "1.2.3", @@ -241,6 +601,17 @@ ], "Hash": "f4625e061cb2865f111b47ff163a5ca6" }, + "ps": { + "Package": "ps", + "Version": "1.7.7", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "utils" + ], + "Hash": "878b467580097e9c383acbb16adab57a" + }, "purrr": { "Package": "purrr", "Version": "1.0.2", @@ -256,6 +627,16 @@ ], "Hash": "1cba04a4e9414bdefc9dcaa99649a8dc" }, + "rappdirs": { + "Package": "rappdirs", + "Version": "0.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "5e3c5dc0b071b21fa128676560dbe94d" + }, "readr": { "Package": "readr", "Version": "2.1.5", @@ -279,6 +660,30 @@ ], "Hash": "9de96463d2117f6ac49980577939dfb3" }, + "rematch2": { + "Package": "rematch2", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "tibble" + ], + "Hash": "76c9e04c712a05848ae7a23d2f170a40" + }, + "remotes": { + "Package": "remotes", + "Version": "2.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "methods", + "stats", + "tools", + "utils" + ], + "Hash": "3ee025083e66f18db6cf27b56e23e141" + }, "renv": { "Package": "renv", "Version": "1.0.7", @@ -289,6 +694,16 @@ ], "Hash": "397b7b2a265bc5a7a06852524dabae20" }, + "rex": { + "Package": "rex", + "Version": "1.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "lazyeval" + ], + "Hash": "ae34cd56890607370665bee5bd17812f" + }, "rlang": { "Package": "rlang", "Version": "1.1.4", @@ -300,15 +715,58 @@ ], "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, - "roxygen2": { - "Package": "roxygen2", - "Version": "7.3.2", - "Source": "Repository" + "rprojroot": { + "Package": "rprojroot", + "Version": "2.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "4c8415e0ec1e29f3f4f6fc108bef0144" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.16.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "96710351d642b70e8f02ddeb237c46a7" + }, + "sys": { + "Package": "sys", + "Version": "3.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3a1be13d68d47a8cd0bfd74739ca1555" }, "testthat": { "Package": "testthat", "Version": "3.2.1.1", - "Source": "Repository" + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "brio", + "callr", + "cli", + "desc", + "digest", + "evaluate", + "jsonlite", + "lifecycle", + "magrittr", + "methods", + "pkgload", + "praise", + "processx", + "ps", + "rlang", + "utils", + "waldo", + "withr" + ], + "Hash": "3f6e7e5e2220856ff865e4834766bf2b" }, "tibble": { "Package": "tibble", @@ -359,7 +817,33 @@ "usethis": { "Package": "usethis", "Version": "3.0.0", - "Source": "Repository" + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "clipr", + "crayon", + "curl", + "desc", + "fs", + "gert", + "gh", + "glue", + "jsonlite", + "lifecycle", + "purrr", + "rappdirs", + "rlang", + "rprojroot", + "rstudioapi", + "stats", + "utils", + "whisker", + "withr", + "yaml" + ], + "Hash": "b2fbf93c2127bedd2cbe9b799530d5d2" }, "utf8": { "Package": "utf8", @@ -411,6 +895,30 @@ ], "Hash": "390f9315bc0025be03012054103d227c" }, + "waldo": { + "Package": "waldo", + "Version": "0.5.3", + "Source": "Repository", + "Repository": "RSPM", + "Requirements": [ + "R", + "cli", + "diffobj", + "glue", + "methods", + "rematch2", + "rlang", + "tibble" + ], + "Hash": "16aa934a49658677d8041df9017329b9" + }, + "whisker": { + "Package": "whisker", + "Version": "0.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c6abfa47a46d281a7d5159d0a8891e88" + }, "withr": { "Package": "withr", "Version": "3.0.1", @@ -422,6 +930,56 @@ "graphics" ], "Hash": "07909200e8bbe90426fbfeb73e1e27aa" + }, + "xfun": { + "Package": "xfun", + "Version": "0.47", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "grDevices", + "stats", + "tools" + ], + "Hash": "36ab21660e2d095fef0d83f689e0477c" + }, + "xml2": { + "Package": "xml2", + "Version": "1.3.6", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "methods", + "rlang" + ], + "Hash": "1d0336142f4cd25d8d23cd3ba7a8fb61" + }, + "xmlparsedata": { + "Package": "xmlparsedata", + "Version": "1.0.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "45e4bf3c46476896e821fc0a408fb4fc" + }, + "yaml": { + "Package": "yaml", + "Version": "2.3.10", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "51dab85c6c98e50a18d7551e9d49f76c" + }, + "zip": { + "Package": "zip", + "Version": "2.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fcc4bd8e6da2d2011eb64a5e5cc685ab" } } } From 02e3994540539046eeb80e172c1370977c2657de Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Thu, 29 Aug 2024 09:47:00 +0100 Subject: [PATCH 14/21] Add version to returned bundles --- R/bundles.R | 5 +++-- tests/testthat/test-bundles.R | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/R/bundles.R b/R/bundles.R index 1b2bb61..21025c0 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -7,7 +7,7 @@ #' @description If a bundle has multiple names, then the id will be duplicated across rows #' #' @param version Requested version, if not defined, the latest will be used -#' @return dataframe that contains a concept_name and a domain column for each available concept +#' @return dataframe that contains a "concept_name", "version" and a "domain" column for each available concept #' @export #' @examples #' available_bundles() @@ -17,7 +17,8 @@ available_bundles <- function(version = "latest") { directories <- list.dirs(raw_dir, full.names = TRUE) domain_directories <- directories[directories != raw_dir] - purrr::map_dfr(domain_directories, .build_concepts_from_directory) + purrr::map_dfr(domain_directories, .build_concepts_from_directory) |> + mutate(version = version) } .get_raw_dir <- function(...) { diff --git a/tests/testthat/test-bundles.R b/tests/testthat/test-bundles.R index 5c4ba2e..2df89f9 100644 --- a/tests/testthat/test-bundles.R +++ b/tests/testthat/test-bundles.R @@ -3,9 +3,14 @@ library(omopbundles) library(testthat) -test_that("available_bundles is not empty", { - result <- available_bundles() +test_that("available_bundles isn't empty and have correct columns", { + result <- omopbundles::available_bundles() expect_true(nrow(result) > 0, info = "The dataframe should not be empty") + hiv_ab <- filter(result, concept_name == "antibodies to hiv") + expect_equal(hiv_ab$version, "latest") + expect_equal(hiv_ab$id, "antibodies_to_hiv.csv") + expect_equal(hiv_ab$domain, "measurement") + }) test_that("Smoking exists as an observation", { From f2aba71c6bfb6aacb8238c88cd2c84fe6cc6f7e0 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Thu, 29 Aug 2024 09:47:00 +0100 Subject: [PATCH 15/21] Add version to returned bundles --- R/bundles.R | 7 ++++--- man/available_bundles.Rd | 4 ++-- tests/testthat/test-bundles.R | 9 +++++++-- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/R/bundles.R b/R/bundles.R index 1b2bb61..c4c7605 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -7,17 +7,18 @@ #' @description If a bundle has multiple names, then the id will be duplicated across rows #' #' @param version Requested version, if not defined, the latest will be used -#' @return dataframe that contains a concept_name and a domain column for each available concept +#' @return dataframe that contains a "concept_name", "version" and a "domain" column for each available concept #' @export #' @examples #' available_bundles() -#' available_bundles('0.1') +#' available_bundles("0.1") available_bundles <- function(version = "latest") { raw_dir <- .get_raw_dir() directories <- list.dirs(raw_dir, full.names = TRUE) domain_directories <- directories[directories != raw_dir] - purrr::map_dfr(domain_directories, .build_concepts_from_directory) + purrr::map_dfr(domain_directories, .build_concepts_from_directory) |> + mutate(version = version) } .get_raw_dir <- function(...) { diff --git a/man/available_bundles.Rd b/man/available_bundles.Rd index 8cc7da7..b0ef742 100644 --- a/man/available_bundles.Rd +++ b/man/available_bundles.Rd @@ -10,12 +10,12 @@ available_bundles(version = "latest") \item{version}{Requested version, if not defined, the latest will be used} } \value{ -dataframe that contains a concept_name and a domain column for each available concept +dataframe that contains a "concept_name", "version" and a "domain" column for each available concept } \description{ If a bundle has multiple names, then the id will be duplicated across rows } \examples{ available_bundles() -available_bundles('0.1') +available_bundles("0.1") } diff --git a/tests/testthat/test-bundles.R b/tests/testthat/test-bundles.R index 5c4ba2e..2df89f9 100644 --- a/tests/testthat/test-bundles.R +++ b/tests/testthat/test-bundles.R @@ -3,9 +3,14 @@ library(omopbundles) library(testthat) -test_that("available_bundles is not empty", { - result <- available_bundles() +test_that("available_bundles isn't empty and have correct columns", { + result <- omopbundles::available_bundles() expect_true(nrow(result) > 0, info = "The dataframe should not be empty") + hiv_ab <- filter(result, concept_name == "antibodies to hiv") + expect_equal(hiv_ab$version, "latest") + expect_equal(hiv_ab$id, "antibodies_to_hiv.csv") + expect_equal(hiv_ab$domain, "measurement") + }) test_that("Smoking exists as an observation", { From 9edf74dabe9622257ae635874e872b1eb20236ef Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Thu, 29 Aug 2024 15:09:37 +0100 Subject: [PATCH 16/21] Add usage examples for concept_by_bundle --- R/bundles.R | 3 +++ man/concept_by_bundle.Rd | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/R/bundles.R b/R/bundles.R index c4c7605..f1f3586 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -43,6 +43,9 @@ available_bundles <- function(version = "latest") { #' @param bundle_row Single row of a dataframe with a domain and id #' @return Dataframe with a concept_id and domain column #' @export +#' @examples +#' available_bundles() |> dplyr::filter(concept_name == "smoking") |> concept_by_bundle() +#' dplyr::tibble(id = "smoking", domain = "observation", version = "latest") |> concept_by_bundle() concept_by_bundle <- function(bundle_row) { stopifnot(is.data.frame(bundle_row)) stopifnot(nrow(bundle_row) == 1) diff --git a/man/concept_by_bundle.Rd b/man/concept_by_bundle.Rd index bd11479..3089a8e 100644 --- a/man/concept_by_bundle.Rd +++ b/man/concept_by_bundle.Rd @@ -15,3 +15,7 @@ Dataframe with a concept_id and domain column \description{ Get concepts for a a single bundle row } +\examples{ +available_bundles() |> dplyr::filter(concept_name == "smoking") |> concept_by_bundle() +dplyr::tibble(id = "smoking", domain = "observation", version = "latest") |> concept_by_bundle() +} From 853ecede358e88b27f12da5756a94e6315f0602e Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Thu, 29 Aug 2024 16:55:53 +0100 Subject: [PATCH 17/21] Use correct id --- R/bundles.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/bundles.R b/R/bundles.R index f1f3586..b06e94b 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -45,7 +45,7 @@ available_bundles <- function(version = "latest") { #' @export #' @examples #' available_bundles() |> dplyr::filter(concept_name == "smoking") |> concept_by_bundle() -#' dplyr::tibble(id = "smoking", domain = "observation", version = "latest") |> concept_by_bundle() +#' dplyr::tibble(id = "smoking.csv", domain = "observation", version = "latest") |> concept_by_bundle() concept_by_bundle <- function(bundle_row) { stopifnot(is.data.frame(bundle_row)) stopifnot(nrow(bundle_row) == 1) From 3dde6029a5abbf8694428f995d1f3c9b1b0beb5a Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Thu, 29 Aug 2024 17:20:42 +0100 Subject: [PATCH 18/21] Use correct id --- man/concept_by_bundle.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/concept_by_bundle.Rd b/man/concept_by_bundle.Rd index 3089a8e..849a1c4 100644 --- a/man/concept_by_bundle.Rd +++ b/man/concept_by_bundle.Rd @@ -17,5 +17,5 @@ Get concepts for a a single bundle row } \examples{ available_bundles() |> dplyr::filter(concept_name == "smoking") |> concept_by_bundle() -dplyr::tibble(id = "smoking", domain = "observation", version = "latest") |> concept_by_bundle() +dplyr::tibble(id = "smoking.csv", domain = "observation", version = "latest") |> concept_by_bundle() } From 843c9c01fa8ce9de9ca9ff9d43cd18cc56aa35aa Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Mon, 2 Sep 2024 10:19:16 +0100 Subject: [PATCH 19/21] Make concepts by bundle an s3 generic --- R/bundles.R | 32 ++++++++++++++++++++------------ man/concept_by_bundle.Rd | 19 +++++++++++++------ tests/testthat/test-bundles.R | 10 ++++++++-- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/R/bundles.R b/R/bundles.R index b06e94b..b4ce9b7 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -13,7 +13,7 @@ #' available_bundles() #' available_bundles("0.1") available_bundles <- function(version = "latest") { - raw_dir <- .get_raw_dir() + raw_dir <- .get_raw_dir(version = version) directories <- list.dirs(raw_dir, full.names = TRUE) domain_directories <- directories[directories != raw_dir] @@ -21,7 +21,9 @@ available_bundles <- function(version = "latest") { mutate(version = version) } -.get_raw_dir <- function(...) { +.get_raw_dir <- function(version, ...) { + if (version != "latest") warning("Versioning not yet implemented, using version = 'latest'") + system.file("data-raw", ..., package = "omopbundles", mustWork = TRUE) } @@ -38,19 +40,25 @@ available_bundles <- function(version = "latest") { dplyr::mutate(concept_name = gsub("_", " ", concept_name)) } + #' @title Get concepts for a a single bundle row #' -#' @param bundle_row Single row of a dataframe with a domain and id -#' @return Dataframe with a concept_id and domain column +#' @description Retrieves concept data for a specific bundle. +#' +#' @param domain The domain of the bundle. +#' @param id The ID of the bundle. +#' @param version The version of the bundle. Default is "latest". +#' @return A data frame with the concept data. #' @export #' @examples -#' available_bundles() |> dplyr::filter(concept_name == "smoking") |> concept_by_bundle() -#' dplyr::tibble(id = "smoking.csv", domain = "observation", version = "latest") |> concept_by_bundle() -concept_by_bundle <- function(bundle_row) { - stopifnot(is.data.frame(bundle_row)) - stopifnot(nrow(bundle_row) == 1) - - .get_raw_dir(bundle_row$domain, bundle_row$id) |> +#' # Usage with available_bundles, from a single row +#' smoking_info <- available_bundles() |> dplyr::filter(concept_name == "smoking") +#' concept_by_bundle(domain = smoking_info$domain, id = smoking_info$id, version = smoking_info$version) +#' # Using if you know the details directly +#' concept_by_bundle(domain = "observation", id = "smoking.csv") +concept_by_bundle <- function(domain, id, version = "latest") { + .get_raw_dir(version = version, domain, id) |> readr::read_csv(show_col_types = FALSE) |> - dplyr::mutate(domain = bundle_row$domain) + dplyr::mutate(domain = domain) } + diff --git a/man/concept_by_bundle.Rd b/man/concept_by_bundle.Rd index 849a1c4..6a52e54 100644 --- a/man/concept_by_bundle.Rd +++ b/man/concept_by_bundle.Rd @@ -4,18 +4,25 @@ \alias{concept_by_bundle} \title{Get concepts for a a single bundle row} \usage{ -concept_by_bundle(bundle_row) +concept_by_bundle(domain, id, version = "latest") } \arguments{ -\item{bundle_row}{Single row of a dataframe with a domain and id} +\item{domain}{The domain of the bundle.} + +\item{id}{The ID of the bundle.} + +\item{version}{The version of the bundle. Default is "latest".} } \value{ -Dataframe with a concept_id and domain column +A data frame with the concept data. } \description{ -Get concepts for a a single bundle row +Retrieves concept data for a specific bundle. } \examples{ -available_bundles() |> dplyr::filter(concept_name == "smoking") |> concept_by_bundle() -dplyr::tibble(id = "smoking.csv", domain = "observation", version = "latest") |> concept_by_bundle() +# Using with the rest of the package +smoking_info <- available_bundles() |> dplyr::filter(concept_name == "smoking") +concept_by_bundle(domain = smoking_info$domain, id = smoking_info$id, version = smoking_info$version) +# Using if you know the details directly +concept_by_bundle(domain = "observation", id = "smoking.csv") } diff --git a/tests/testthat/test-bundles.R b/tests/testthat/test-bundles.R index 2df89f9..af8d0b3 100644 --- a/tests/testthat/test-bundles.R +++ b/tests/testthat/test-bundles.R @@ -21,12 +21,18 @@ test_that("Smoking exists as an observation", { expect_equal(result$domain, "observation") }) +test_that("Concept by bundle works with character values", { + smoking_concepts <- omopbundles::concept_by_bundle(domain = "observation", id = "smoking.csv") + expect_true(nrow(smoking_concepts) > 1, info = "Smoking should have multiple concepts") + expect_false(any(is.na(smoking_concepts$concept_id)), info = "Concept ids should not be NA") + expect_true(all(smoking_concepts$domain == "observation"), info = "Domain should be set correctly") +}) -test_that("Avilable bundles and concept_by_bundle play nicely together", { +test_that("Available bundles and concept_by_bundle play nicely together", { smoking_bundle <- available_bundles() |> dplyr::filter(concept_name == "smoking") - smoking_concepts <- concept_by_bundle(smoking_bundle) + smoking_concepts <- concept_by_bundle(smoking_bundle$domain, smoking_bundle$id) expect_true(nrow(smoking_concepts) > 1, info = "Smoking should have multiple concepts") expect_false(any(is.na(smoking_concepts$concept_id)), info = "Concept ids should not be NA") From 8d2a9cb3211fc625b667936625ec86a41e2165a9 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Mon, 2 Sep 2024 10:45:48 +0100 Subject: [PATCH 20/21] Make linter happy --- R/bundles.R | 1 - 1 file changed, 1 deletion(-) diff --git a/R/bundles.R b/R/bundles.R index b4ce9b7..9b579ab 100644 --- a/R/bundles.R +++ b/R/bundles.R @@ -61,4 +61,3 @@ concept_by_bundle <- function(domain, id, version = "latest") { readr::read_csv(show_col_types = FALSE) |> dplyr::mutate(domain = domain) } - From d2ae038ddbedddc560daf3cceaa93608d8812f62 Mon Sep 17 00:00:00 2001 From: Stef Piatek Date: Mon, 2 Sep 2024 10:47:58 +0100 Subject: [PATCH 21/21] Add devtools to developer packages --- DESCRIPTION | 1 + renv.lock | 579 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 580 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 202ad8a..a4aa4ad 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -12,6 +12,7 @@ Imports: purrr (>= 1.0), readr (>= 2.0) Suggests: + devtools, usethis, testthat (>= 3.0.0), lintr, diff --git a/renv.lock b/renv.lock index 4ddfadb..ca13401 100644 --- a/renv.lock +++ b/renv.lock @@ -19,6 +19,17 @@ ], "Hash": "470851b6d5d0ac559e9d01bb352b4021" }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.13", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "methods", + "utils" + ], + "Hash": "f27411eb6d9c3dada5edd444b8416675" + }, "askpass": { "Package": "askpass", "Version": "1.2.0", @@ -39,6 +50,16 @@ ], "Hash": "e1e1b9d75c37401117b636b7ae50827a" }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, "bit": { "Package": "bit", "Version": "4.0.5", @@ -63,6 +84,13 @@ ], "Hash": "9fe98599ca456d6552421db0d6772d8f" }, + "brew": { + "Package": "brew", + "Version": "1.0-10", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "8f4a384e19dccd8c65356dc096847b76" + }, "brio": { "Package": "brio", "Version": "1.1.5", @@ -73,6 +101,39 @@ ], "Hash": "c1ee497a6d999947c2c224ae46799b1a" }, + "bslib": { + "Package": "bslib", + "Version": "0.8.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "base64enc", + "cachem", + "fastmap", + "grDevices", + "htmltools", + "jquerylib", + "jsonlite", + "lifecycle", + "memoise", + "mime", + "rlang", + "sass" + ], + "Hash": "b299c6741ca9746fb227debcb0f9fb6c" + }, + "cachem": { + "Package": "cachem", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "fastmap", + "rlang" + ], + "Hash": "cd9a672193789068eb5a2aad65a0dedf" + }, "callr": { "Package": "callr", "Version": "3.7.6", @@ -117,6 +178,13 @@ ], "Hash": "61e097f35917d342622f21cdc79c256e" }, + "commonmark": { + "Package": "commonmark", + "Version": "1.9.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5d8225445acb167abf7797de48b2ee3c" + }, "cpp11": { "Package": "cpp11", "Version": "0.5.0", @@ -190,6 +258,40 @@ ], "Hash": "99b79fcbd6c4d1ce087f5c5c758b384f" }, + "devtools": { + "Package": "devtools", + "Version": "2.4.5", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "desc", + "ellipsis", + "fs", + "lifecycle", + "memoise", + "miniUI", + "pkgbuild", + "pkgdown", + "pkgload", + "profvis", + "rcmdcheck", + "remotes", + "rlang", + "roxygen2", + "rversions", + "sessioninfo", + "stats", + "testthat", + "tools", + "urlchecker", + "usethis", + "utils", + "withr" + ], + "Hash": "ea5bc8b4a6a01e4f12d98b58329930bb" + }, "diffobj": { "Package": "diffobj", "Version": "0.3.5", @@ -216,6 +318,26 @@ ], "Hash": "33698c4b3127fc9f506654607fb73676" }, + "downlit": { + "Package": "downlit", + "Version": "0.4.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "brio", + "desc", + "digest", + "evaluate", + "fansi", + "memoise", + "rlang", + "vctrs", + "withr", + "yaml" + ], + "Hash": "45a6a596bf0108ee1ff16a040a2df897" + }, "dplyr": { "Package": "dplyr", "Version": "1.1.4", @@ -239,6 +361,17 @@ ], "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "rlang" + ], + "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" + }, "evaluate": { "Package": "evaluate", "Version": "0.24.0", @@ -262,6 +395,25 @@ ], "Hash": "962174cf2aeb5b9eea581522286a911f" }, + "fastmap": { + "Package": "fastmap", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "aa5e1cd11c2d15497494c5292d7ffcc8" + }, + "fontawesome": { + "Package": "fontawesome", + "Version": "0.5.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "htmltools", + "rlang" + ], + "Hash": "c2efdd5f0bcd1ea861c2d4e2a883a67d" + }, "fs": { "Package": "fs", "Version": "1.6.4", @@ -363,6 +515,52 @@ ], "Hash": "b59377caa7ed00fa41808342002138f9" }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.8.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "base64enc", + "digest", + "fastmap", + "grDevices", + "rlang", + "utils" + ], + "Hash": "81d371a9cc60640e74e4ab6ac46dcedc" + }, + "htmlwidgets": { + "Package": "htmlwidgets", + "Version": "1.6.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "grDevices", + "htmltools", + "jsonlite", + "knitr", + "rmarkdown", + "yaml" + ], + "Hash": "04291cc45198225444a397606810ac37" + }, + "httpuv": { + "Package": "httpuv", + "Version": "1.6.15", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "Rcpp", + "later", + "promises", + "utils" + ], + "Hash": "d55aa087c47a63ead0f6fc10f8fa1ee0" + }, "httr2": { "Package": "httr2", "Version": "1.0.3", @@ -391,6 +589,16 @@ "Repository": "CRAN", "Hash": "6154ec2223172bce8162d4153cda21f7" }, + "jquerylib": { + "Package": "jquerylib", + "Version": "0.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "htmltools" + ], + "Hash": "5aab57a3bd297eee1c1d862735972182" + }, "jsonlite": { "Package": "jsonlite", "Version": "1.8.8", @@ -417,6 +625,17 @@ ], "Hash": "acf380f300c721da9fde7df115a5f86f" }, + "later": { + "Package": "later", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "Rcpp", + "rlang" + ], + "Hash": "a3e051d405326b8b0012377434c62b37" + }, "lazyeval": { "Package": "lazyeval", "Version": "0.2.2", @@ -471,6 +690,39 @@ ], "Hash": "7ce2733a9826b3aeb1775d56fd305472" }, + "memoise": { + "Package": "memoise", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "cachem", + "rlang" + ], + "Hash": "e2817ccf4a065c5d9d7f2cfbe7c1d78c" + }, + "mime": { + "Package": "mime", + "Version": "0.12", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "tools" + ], + "Hash": "18e9c28c1d3ca1560ce30658b22ce104" + }, + "miniUI": { + "Package": "miniUI", + "Version": "0.1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "htmltools", + "shiny", + "utils" + ], + "Hash": "fec5f52652d60615fdb3957b3d74324a" + }, "openssl": { "Package": "openssl", "Version": "2.2.1", @@ -535,6 +787,36 @@ ], "Hash": "01f28d4278f15c76cddbea05899c5d6f" }, + "pkgdown": { + "Package": "pkgdown", + "Version": "2.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "bslib", + "callr", + "cli", + "desc", + "digest", + "downlit", + "fontawesome", + "fs", + "httr2", + "jsonlite", + "openssl", + "purrr", + "ragg", + "rlang", + "rmarkdown", + "tibble", + "whisker", + "withr", + "xml2", + "yaml" + ], + "Hash": "0d3d789055c873f48521ce7e23c23f48" + }, "pkgload": { "Package": "pkgload", "Version": "1.4.0", @@ -587,6 +869,21 @@ ], "Hash": "0c90a7d71988856bad2a2a45dd871bb9" }, + "profvis": { + "Package": "profvis", + "Version": "0.3.8", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "htmlwidgets", + "purrr", + "rlang", + "stringr", + "vctrs" + ], + "Hash": "aa5a3864397ce6ae03458f98618395a1" + }, "progress": { "Package": "progress", "Version": "1.2.3", @@ -601,6 +898,22 @@ ], "Hash": "f4625e061cb2865f111b47ff163a5ca6" }, + "promises": { + "Package": "promises", + "Version": "1.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R6", + "Rcpp", + "fastmap", + "later", + "magrittr", + "rlang", + "stats" + ], + "Hash": "434cd5388a3979e74be5c219bcd6e77d" + }, "ps": { "Package": "ps", "Version": "1.7.7", @@ -627,6 +940,17 @@ ], "Hash": "1cba04a4e9414bdefc9dcaa99649a8dc" }, + "ragg": { + "Package": "ragg", + "Version": "1.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "systemfonts", + "textshaping" + ], + "Hash": "e3087db406e079a8a2fd87f413918ed3" + }, "rappdirs": { "Package": "rappdirs", "Version": "0.3.3", @@ -637,6 +961,28 @@ ], "Hash": "5e3c5dc0b071b21fa128676560dbe94d" }, + "rcmdcheck": { + "Package": "rcmdcheck", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R6", + "callr", + "cli", + "curl", + "desc", + "digest", + "pkgbuild", + "prettyunits", + "rprojroot", + "sessioninfo", + "utils", + "withr", + "xopen" + ], + "Hash": "8f25ebe2ec38b1f2aef3b0d2ef76f6c4" + }, "readr": { "Package": "readr", "Version": "2.1.5", @@ -715,6 +1061,55 @@ ], "Hash": "3eec01f8b1dee337674b2e34ab1f9bc1" }, + "rmarkdown": { + "Package": "rmarkdown", + "Version": "2.28", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "bslib", + "evaluate", + "fontawesome", + "htmltools", + "jquerylib", + "jsonlite", + "knitr", + "methods", + "tinytex", + "tools", + "utils", + "xfun", + "yaml" + ], + "Hash": "062470668513dcda416927085ee9bdc7" + }, + "roxygen2": { + "Package": "roxygen2", + "Version": "7.3.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "brew", + "cli", + "commonmark", + "cpp11", + "desc", + "knitr", + "methods", + "pkgload", + "purrr", + "rlang", + "stringi", + "stringr", + "utils", + "withr", + "xml2" + ], + "Hash": "6ee25f9054a70f44d615300ed531ba8d" + }, "rprojroot": { "Package": "rprojroot", "Version": "2.0.4", @@ -732,6 +1127,118 @@ "Repository": "CRAN", "Hash": "96710351d642b70e8f02ddeb237c46a7" }, + "rversions": { + "Package": "rversions", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "curl", + "utils", + "xml2" + ], + "Hash": "a9881dfed103e83f9de151dc17002cd1" + }, + "sass": { + "Package": "sass", + "Version": "0.4.9", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R6", + "fs", + "htmltools", + "rappdirs", + "rlang" + ], + "Hash": "d53dbfddf695303ea4ad66f86e99b95d" + }, + "sessioninfo": { + "Package": "sessioninfo", + "Version": "1.2.2", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "tools", + "utils" + ], + "Hash": "3f9796a8d0a0e8c6eb49a4b029359d1f" + }, + "shiny": { + "Package": "shiny", + "Version": "1.9.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "R6", + "bslib", + "cachem", + "commonmark", + "crayon", + "fastmap", + "fontawesome", + "glue", + "grDevices", + "htmltools", + "httpuv", + "jsonlite", + "later", + "lifecycle", + "methods", + "mime", + "promises", + "rlang", + "sourcetools", + "tools", + "utils", + "withr", + "xtable" + ], + "Hash": "6a293995a66e12c48d13aa1f957d09c7" + }, + "sourcetools": { + "Package": "sourcetools", + "Version": "0.1.7-1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R" + ], + "Hash": "5f5a7629f956619d519205ec475fe647" + }, + "stringi": { + "Package": "stringi", + "Version": "1.8.4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "stats", + "tools", + "utils" + ], + "Hash": "39e1144fd75428983dc3f63aa53dfa91" + }, + "stringr": { + "Package": "stringr", + "Version": "1.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "glue", + "lifecycle", + "magrittr", + "rlang", + "stringi", + "vctrs" + ], + "Hash": "960e2ae9e09656611e0b8214ad543207" + }, "sys": { "Package": "sys", "Version": "3.4.2", @@ -739,6 +1246,18 @@ "Repository": "CRAN", "Hash": "3a1be13d68d47a8cd0bfd74739ca1555" }, + "systemfonts": { + "Package": "systemfonts", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cpp11", + "lifecycle" + ], + "Hash": "213b6b8ed5afbf934843e6c3b090d418" + }, "testthat": { "Package": "testthat", "Version": "3.2.1.1", @@ -768,6 +1287,19 @@ ], "Hash": "3f6e7e5e2220856ff865e4834766bf2b" }, + "textshaping": { + "Package": "textshaping", + "Version": "0.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cpp11", + "lifecycle", + "systemfonts" + ], + "Hash": "5142f8bc78ed3d819d26461b641627ce" + }, "tibble": { "Package": "tibble", "Version": "3.2.1", @@ -803,6 +1335,16 @@ ], "Hash": "829f27b9c4919c16b593794a6344d6c0" }, + "tinytex": { + "Package": "tinytex", + "Version": "0.52", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "xfun" + ], + "Hash": "cfbad971a71f0e27cec22e544a08bc3b" + }, "tzdb": { "Package": "tzdb", "Version": "0.4.0", @@ -814,6 +1356,20 @@ ], "Hash": "f561504ec2897f4d46f0c7657e488ae1" }, + "urlchecker": { + "Package": "urlchecker", + "Version": "1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "cli", + "curl", + "tools", + "xml2" + ], + "Hash": "409328b8e1253c8d729a7836fe7f7a16" + }, "usethis": { "Package": "usethis", "Version": "3.0.0", @@ -967,6 +1523,29 @@ ], "Hash": "45e4bf3c46476896e821fc0a408fb4fc" }, + "xopen": { + "Package": "xopen", + "Version": "1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "processx" + ], + "Hash": "423df1e86d5533fcb73c6b02b4923b49" + }, + "xtable": { + "Package": "xtable", + "Version": "1.8-4", + "Source": "Repository", + "Repository": "CRAN", + "Requirements": [ + "R", + "stats", + "utils" + ], + "Hash": "b8acdf8af494d9ec19ccb2481a9b11c2" + }, "yaml": { "Package": "yaml", "Version": "2.3.10",