From 34ab9ea16e98f72e0ce060825a1ff8cfc3ac1566 Mon Sep 17 00:00:00 2001 From: Collin Schwantes Date: Mon, 5 Aug 2024 10:02:22 -0600 Subject: [PATCH 1/3] Increment version number to 0.3.1 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 335bb16..2337651 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ohcleandat Type: Package Title: One Health Data Cleaning and Quality Checking Package -Version: 0.3.0 +Version: 0.3.1 Authors@R: c( person("Collin", "Schwantes", email = "schwantes@ecohealthalliance.org", role = c("cre", "aut"), comment = c(ORCID = "0000-0003-4014-4896")), person("Johana", "Teigen", email = "teigen@ecohealthalliance.org", role = "aut", comment = c(ORCID = "0000-0002-6209-2321")), diff --git a/NEWS.md b/NEWS.md index e14876f..41a9aea 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,5 @@ +# ohcleandat 0.3.1 + # ohcleandat 0.3.0 * Adding GPS obfuscation function - this function uses two methods to reduce the From 52f72fc34c8b14c468160f3d1672e4ccd3cfbef5 Mon Sep 17 00:00:00 2001 From: Collin Schwantes Date: Mon, 5 Aug 2024 10:02:51 -0600 Subject: [PATCH 2/3] adding set_diff function explicitly --- NAMESPACE | 1 + R/set_diff.R | 37 +++++++++++++++++++++++++++++++++++++ R/zzz.R | 1 - man/set_diff.Rd | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 R/set_diff.R create mode 100644 man/set_diff.Rd diff --git a/NAMESPACE b/NAMESPACE index a3a77b6..512612f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,6 +28,7 @@ export(othertext_lookup) export(read_excel_all_sheets) export(read_googlesheets) export(remove_deletions) +export(set_diff) export(validation_checks) importFrom(dplyr,"%>%") importFrom(rlang,":=") diff --git a/R/set_diff.R b/R/set_diff.R new file mode 100644 index 0000000..b35a36e --- /dev/null +++ b/R/set_diff.R @@ -0,0 +1,37 @@ +#' Get items that differ between x and y +#' +#' Unlike setdiff, this function creates the union of x and y then +#' removes values that are in the intersect, providing values +#' that are unique to X and values that are unique to Y. +#' +#' @param x a set of values. +#' @param y a set of values. +#' +#' @return Unique values from X and Y, NULL if no unique values. +#' @export +#' +#' @examples +#' a <- 1:3 +#' b <- 2:4 +#' +#' set_diff(a,b) +#' # returns 1,4 +#' +#' x <- 1:3 +#' y <- 1:3 +#' +#' set_diff(x,y) +#' # returns NULL +#' +set_diff <- function(x,y){ + u <- union(x,y) + i <- intersect(x,y) + j <- (u %in% i) + + if(all(j)){ + return(NULL) + } + + diff <- u[!(j)] + return(diff) +} diff --git a/R/zzz.R b/R/zzz.R index dafdbcd..dd2d7a8 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -28,7 +28,6 @@ utils::globalVariables( "log_response_id", "n", "rowid", - "set_diff", "entry_field", "entry_field_dupe" ) diff --git a/man/set_diff.Rd b/man/set_diff.Rd new file mode 100644 index 0000000..956590f --- /dev/null +++ b/man/set_diff.Rd @@ -0,0 +1,35 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/set_diff.R +\name{set_diff} +\alias{set_diff} +\title{Get items that differ between x and y} +\usage{ +set_diff(x, y) +} +\arguments{ +\item{x}{a set of values.} + +\item{y}{a set of values.} +} +\value{ +Unique values from X and Y, NULL if no unique values. +} +\description{ +Unlike setdiff, this function creates the union of x and y then +removes values that are in the intersect, providing values +that are unique to X and values that are unique to Y. +} +\examples{ +a <- 1:3 +b <- 2:4 + +set_diff(a,b) +# returns 1,4 + +x <- 1:3 +y <- 1:3 + +set_diff(x,y) +# returns NULL + +} From d2aa1b712d94e32499ba87506670fd06a6812855 Mon Sep 17 00:00:00 2001 From: Collin Schwantes Date: Mon, 5 Aug 2024 10:04:36 -0600 Subject: [PATCH 3/3] Update NEWS.md --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index 41a9aea..f42edd5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # ohcleandat 0.3.1 +* Explicitly adding `set_diff` function which was previously a hidden dependency on the {ecohealthalliance/airtabler} package + # ohcleandat 0.3.0 * Adding GPS obfuscation function - this function uses two methods to reduce the