diff --git a/NAMESPACE b/NAMESPACE index 6afa2fa..5af9aae 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -21,6 +21,7 @@ export(summarizeS3Objects) export(tgrAnnotate) export(tgrDefinitions) export(undefinedAnnotations) +export(unusedAnnotations) export(usedIdentifiers) export(validateDataFrame) export(validateDataset) diff --git a/R/annotationfunctions.R b/R/annotationfunctions.R index 08e98bb..14fb104 100644 --- a/R/annotationfunctions.R +++ b/R/annotationfunctions.R @@ -29,7 +29,7 @@ undefinedAnnotations <- function() { stop("You have missing environment variables. Please set creds in env vars.")} else message("Credentials set successfully.") commonKnowledge <- tgrDefinitions() - sciMeta <- tgrAnnotate(harmonizedOnly = T, DAG = "all", evenEmptyCols = F) + sciMeta <- tgrAnnotate(harmonizedOnly = T, DAG = "all", evenEmptyCols = T) # Remove project memberships defineMe <- sciMeta %>% dplyr::select(-dplyr::starts_with("data_is_")) categorical <- commonKnowledge %>% dplyr::filter(Type == "categorical") @@ -56,3 +56,23 @@ undefinedAnnotations <- function() { return(makeMeaning) } +#' (Admin) Finds unused REDCap variables +#' +#' Pulls sample data down from REDCap and compares them with the defined annotation list in GitHub and identifies variables previously used in REDCap that have definitions in GitHub that need to be removed. +#' +#' @return A data frame that is list in the format of commonKnowledge data in the tgr-annotations repo with annotations and values to remove. +#' @author Amy Paguirigan +#' @details +#' Requires **admin** REDCap credentials to be set in the environment. +#' @export +unusedAnnotations <- function() { + if ("" %in% Sys.getenv(c("REDURI", "TGR", "S3A", "S3SA"))) { + stop("You have missing environment variables. Please set creds in env vars.")} + else message("Credentials set successfully.") + commonKnowledge <- tgrDefinitions() + sciMeta <- tgrAnnotate(harmonizedOnly = F, DAG = "all", evenEmptyCols = T) + unused <- commonKnowledge %>% dplyr::filter(!Annotation %in% colnames(sciMeta)) %>% dplyr::filter(Category != "Bioinformatics") + + return(unused) +} + diff --git a/man/unusedAnnotations.Rd b/man/unusedAnnotations.Rd new file mode 100644 index 0000000..1685e75 --- /dev/null +++ b/man/unusedAnnotations.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotationfunctions.R +\name{unusedAnnotations} +\alias{unusedAnnotations} +\title{(Admin) Finds unused REDCap variables} +\usage{ +unusedAnnotations() +} +\value{ +A data frame that is list in the format of commonKnowledge data in the tgr-annotations repo with annotations and values to remove. +} +\description{ +Pulls sample data down from REDCap and compares them with the defined annotation list in GitHub and identifies variables previously used in REDCap that have definitions in GitHub that need to be removed. +} +\details{ +Requires **admin** REDCap credentials to be set in the environment. +} +\author{ +Amy Paguirigan +}