diff --git a/.Rbuildignore b/.Rbuildignore index 6a3d6fc..f49378c 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,4 @@ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ +^CRAN-SUBMISSION$ diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION new file mode 100644 index 0000000..54e3517 --- /dev/null +++ b/CRAN-SUBMISSION @@ -0,0 +1,3 @@ +Version: 0.0.1 +Date: 2025-03-25 16:28:12 UTC +SHA: 5604d351f4f9ba9555d221c81eb5c49da1654358 diff --git a/DESCRIPTION b/DESCRIPTION index 6494104..74868c2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,13 +1,16 @@ Package: meddra.read -Title: Load and Merge MedDRA Data for Clinical Trials -Version: 0.0.0.9000 +Title: Load and Use 'MedDRA' Data for Clinical Trials +Version: 0.0.1 Authors@R: person("Bill", "Denney", email="wdenney@humanpredictions.com", role=c("aut", "cre"), comment=c(ORCID="0000-0002-5759-428X")) Description: - MedDRA data is used for defining adverse events in clinical studies. You + 'MedDRA' data is used for defining adverse events in clinical studies. You can load and merge the data for use in categorizing the adverse events - using this package. + using this package. The package requires the data licensed from 'MedDRA' + . License: MIT + file LICENSE +Imports: + dplyr Suggests: spelling, testthat (>= 3.0.0) @@ -15,7 +18,5 @@ Config/testthat/edition: 3 Encoding: UTF-8 Roxygen: list(markdown = TRUE) RoxygenNote: 7.3.2 -Imports: - dplyr URL: https://humanpred.github.io/meddra.read/ Language: en-US diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..1c4549f --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# meddra.read 0.0.1 + +* Initial CRAN submission. diff --git a/R/join_meddra.R b/R/join_meddra.R index cb81026..6575c9a 100644 --- a/R/join_meddra.R +++ b/R/join_meddra.R @@ -4,16 +4,19 @@ #' @return A data.frame with the "soc_code", "soc_name", "soc_abbrev", #' "hlgt_code", "hlgt_name", "hlt_code", "hlt_name", "pt_code", "pt_name", #' "pt_soc_code", "llt_code", "llt_name", and "llt_currency" +#' @examples +#' \dontrun{ +#' meddra_raw <- read_meddra("/path/to/meddra/distribution") +#' meddra_df <- join_meddra(meddra_raw) +#' } #' @export join_meddra <- function(data) { - ret <- - data$soc.asc |> - dplyr::left_join(data$soc_hlgt.asc, by = "soc_code") |> - dplyr::left_join(data$hlgt.asc, by = "hlgt_code") |> - dplyr::left_join(data$hlgt_hlt.asc, by = "hlgt_code") |> - dplyr::left_join(data$hlt.asc, by = "hlt_code") |> - dplyr::left_join(data$hlt_pt.asc, by = "hlt_code") |> - dplyr::left_join(data$pt.asc, by = "pt_code") |> - dplyr::left_join(data$llt.asc, by = "pt_code") + ret <- dplyr::left_join(data$soc.asc, data$soc_hlgt.asc, by = "soc_code") + ret <- dplyr::left_join(ret, data$hlgt.asc, by = "hlgt_code") + ret <- dplyr::left_join(ret, data$hlgt_hlt.asc, by = "hlgt_code") + ret <- dplyr::left_join(ret, data$hlt.asc, by = "hlt_code") + ret <- dplyr::left_join(ret, data$hlt_pt.asc, by = "hlt_code") + ret <- dplyr::left_join(ret, data$pt.asc, by = "pt_code") + ret <- dplyr::left_join(ret, data$llt.asc, by = "pt_code") ret } diff --git a/R/read_meddra.R b/R/read_meddra.R index 51f656c..a5328c9 100644 --- a/R/read_meddra.R +++ b/R/read_meddra.R @@ -3,6 +3,10 @@ #' @param directory the directory containing the MedAscii and SeqAscii #' directories #' @return A list of data.frames for each file in the MedDRA source distribution +#' @examples +#' \dontrun{ +#' read_meddra("/path/to/meddra/distribution") +#' } #' @export read_meddra <- function(directory) { dirs_available <- list.dirs(path = directory, full.names = FALSE) @@ -21,7 +25,7 @@ read_meddra <- function(directory) { read_meddra_dir <- function(directory, extension) { files <- list.files(directory, full.names = TRUE, pattern = sprintf("\\.%s$", extension)) stopifnot(length(files) > 0) - files <- setNames(files, tolower(basename(files)))[order(tolower(basename(files)))] + files <- stats::setNames(files, tolower(basename(files)))[order(tolower(basename(files)))] lapply(X = files, FUN = read_meddra_file) } @@ -121,7 +125,7 @@ read_meddra_file <- function(filename) { )) } else { ret <- - read.delim( + utils::read.delim( # Some files (at least meddra_release.asc in version 28.0) are missing # newlines at the end, this suppresses a warning about that. text = file_text, diff --git a/cran-comments.md b/cran-comments.md new file mode 100644 index 0000000..c0702a1 --- /dev/null +++ b/cran-comments.md @@ -0,0 +1,14 @@ +## R CMD check results + +0 errors | 0 warnings | 1 note + +* From initial review: "Ideally, add small executable examples in your Rd-files + to illustrate the use of the exported function but also enable automatic + testing." + * Due to 'MedDRA' licensing restrictions, I cannot include any actual data + in the package or read it from a remote source. I have added "dontrun" + examples which I know are not preferred. + * For clarity, there are example files intended to test some of the oddities + of loading 'MedDRA' data, but they are not real data. And, I would prefer + not to point users to those files so that they are not confusing to the + user. diff --git a/man/join_meddra.Rd b/man/join_meddra.Rd index 3da0b0d..a4a6fb7 100644 --- a/man/join_meddra.Rd +++ b/man/join_meddra.Rd @@ -17,3 +17,9 @@ A data.frame with the "soc_code", "soc_name", "soc_abbrev", \description{ Combine together all of the MedDRA terms into a single data.frame } +\examples{ +\dontrun{ +meddra_raw <- read_meddra("/path/to/meddra/distribution") +meddra_df <- join_meddra(meddra_raw) +} +} diff --git a/man/read_meddra.Rd b/man/read_meddra.Rd index 526e128..8762313 100644 --- a/man/read_meddra.Rd +++ b/man/read_meddra.Rd @@ -16,3 +16,8 @@ A list of data.frames for each file in the MedDRA source distribution \description{ Read MedDRA datasets from the source MedDRA datasets } +\examples{ +\dontrun{ +read_meddra("/path/to/meddra/distribution") +} +}