Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues simplification #100

Merged
merged 7 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-20.04, r: '3.5', repos: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: '3.6', repos: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
Expand Down
6 changes: 4 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: metacore
Title: A Centralized Metadata Object Focus on Clinical Trial Data Programming Workflows
Version: 0.1.2
Version: 0.1.3
Authors@R:
c(person(given = "Christina",
family = "Fillmore",
Expand All @@ -27,7 +27,9 @@ Description: Create an immutable container holding metadata for the purpose of b
License: MIT + file LICENSE
Encoding: UTF-8
Roxygen: list(markdown = TRUE, r6 = FALSE)
RoxygenNote: 7.2.1
RoxygenNote: 7.3.1
Depends:
R (>= 3.6)
Suggests:
testthat,
knitr,
Expand Down
15 changes: 9 additions & 6 deletions R/metacore.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,17 @@
multiple = "all") %>%
distinct(variable, .keep_all = TRUE) # for when duplicates gett through and have different lables but the same name

# Get values/variables that need derivations
val_deriv <- private$.value_spec %>%
distinct(.data$derivation_id) %>%
na.omit()

private$.derivations <- private$.derivations %>%
right_join(private$.value_spec %>%
select(derivation_id) %>%
na.omit(), by = "derivation_id", multiple = "all")
right_join(val_deriv, by = "derivation_id", multiple = "all")

private$.codelist <- private$.codelist %>%
right_join(private$.value_spec %>%
select(code_id) %>%
distinct(.data$code_id) %>%
na.omit(), by = "code_id", multiple = "all")

private$.supp <- private$.supp %>% filter(dataset == value)
Expand Down Expand Up @@ -330,13 +333,13 @@

if (simplify) {

suppressMessages(
test <- suppressMessages(

Check warning on line 336 in R/metacore.R

View check run for this annotation

Codecov / codecov/patch

R/metacore.R#L336

Added line #L336 was not covered by tests
list(
cl$ds_vars,
cl$var_spec,
cl$value_spec,
cl$derivations,
cl$codelist,
select(cl$codelist, code_id, codes),

Check warning on line 342 in R/metacore.R

View check run for this annotation

Codecov / codecov/patch

R/metacore.R#L342

Added line #L342 was not covered by tests
cl$supp
) %>%
reduce(left_join)
Expand Down
25 changes: 14 additions & 11 deletions R/spec_builder.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#'
#' This function takes the location of an excel specification document and reads
#' it in as a meta core object. At the moment it only supports specification in
#' the format of pinnacle 21 specifications. But, the @family spec builder can
#' be used as building blocks for bespoke specification documents
#' the format of pinnacle 21 specifications. But, the section level spec builder can
#' be used as building blocks for bespoke specification documents.
#'
#' @param path string of file location
#' @param quiet Option to quietly load in, this will suppress warnings, but not
Expand Down Expand Up @@ -96,7 +96,7 @@
#' @return a dataset formatted for the metacore object
#' @export
#'
#' @family spec builder
#' @family {spec builder}
spec_type_to_ds_spec <- function(doc, cols = c("dataset" = "[N|n]ame|[D|d]ataset|[D|d]omain",
"structure" = "[S|s]tructure",
"label" = "[L|l]abel|[D|d]escription"), sheet = NULL){
Expand Down Expand Up @@ -140,7 +140,7 @@
#' @return a dataset formatted for the metacore object
#' @export
#'
#' @family spec builder
#' @family {spec builder}
spec_type_to_ds_vars <- function(doc, cols = c("dataset" = "[D|d]ataset|[D|d]omain",
"variable" = "[V|v]ariable [[N|n]ame]?|[V|v]ariables?",
"order" = "[V|v]ariable [O|o]rder|[O|o]rder",
Expand Down Expand Up @@ -214,7 +214,7 @@
#' @return a dataset formatted for the metacore object
#' @export
#'
#' @family spec builder
#' @family {spec builder}
spec_type_to_var_spec <- function(doc, cols = c("variable" = "[N|n]ame|[V|v]ariables?",
"length" = "[L|l]ength",
"label" = "[L|l]abel",
Expand Down Expand Up @@ -314,7 +314,7 @@
#' @return a dataset formatted for the metacore object
#' @export
#'
#' @family spec builder
#' @family {spec builder}
spec_type_to_value_spec <- function(doc, cols = c("dataset" = "[D|d]ataset|[D|d]omain",
"variable" = "[N|n]ame|[V|v]ariables?",
"origin" = "[O|o]rigin",
Expand Down Expand Up @@ -408,7 +408,10 @@

if(!"derivation_id" %in% names(cols)){
out <- out %>%
mutate(derivation_id = paste0(dataset, ".", variable))
mutate(derivation_id =
if_else(str_to_lower(.data$origin) == "assigned",
paste0(dataset, ".", variable),
paste0("pred.", dataset, ".", variable)))

Check warning on line 414 in R/spec_builder.R

View check run for this annotation

Codecov / codecov/patch

R/spec_builder.R#L411-L414

Added lines #L411 - L414 were not covered by tests
}

# Get missing columns
Expand All @@ -421,7 +424,7 @@
mutate(sig_dig = as.integer(.data$sig_dig),
derivation_id = case_when(
!is.na(.data$derivation_id) ~ .data$derivation_id,
str_to_lower(.data$origin) == "predecessor" ~ as.character(.data$predecessor),
str_to_lower(.data$origin) == "predecessor" ~ paste0("pred.", as.character(.data$predecessor)),
str_to_lower(.data$origin) == "assigned" ~ paste0(.data$dataset, ".", .data$variable))
) %>%
select(-.data$predecessor)
Expand Down Expand Up @@ -453,7 +456,7 @@
#' @return a dataset formatted for the metacore object
#' @export
#'
#' @family spec builder
#' @family {spec builder}
spec_type_to_codelist <- function(doc, codelist_cols = c("code_id" = "ID",
"name" = "[N|n]ame",
"code" = "^[C|c]ode|^[T|t]erm",
Expand Down Expand Up @@ -558,7 +561,7 @@
#' @return a dataset formatted for the metacore object
#' @export
#'
#' @family spec builder
#' @family {spec builder}
#' @importFrom purrr quietly
spec_type_to_derivations <- function(doc, cols = c("derivation_id" = "ID",
"derivation" = "[D|d]efinition|[D|d]escription"),
Expand Down Expand Up @@ -591,7 +594,7 @@
other_derivations <- ls_derivations %>%
mutate(
derivation_id = case_when(
str_to_lower(.data$origin) == "predecessor" ~ as.character(.data$predecessor),
str_to_lower(.data$origin) == "predecessor" ~ paste0("pred.", as.character(.data$predecessor)),
str_to_lower(.data$origin) == "assigned" ~ paste0(.data$dataset, ".", .data$variable),
TRUE ~ NA_character_
),
Expand Down
2 changes: 2 additions & 0 deletions man/get_control_term.Rd

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

4 changes: 2 additions & 2 deletions man/spec_to_metacore.Rd

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

4 changes: 2 additions & 2 deletions man/spec_type_to_codelist.Rd

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

4 changes: 2 additions & 2 deletions man/spec_type_to_derivations.Rd

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

4 changes: 2 additions & 2 deletions man/spec_type_to_ds_spec.Rd

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

4 changes: 2 additions & 2 deletions man/spec_type_to_ds_vars.Rd

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

4 changes: 2 additions & 2 deletions man/spec_type_to_value_spec.Rd

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

4 changes: 2 additions & 2 deletions man/spec_type_to_var_spec.Rd

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

Loading