Commit e3164794 authored by Jonathan Mang's avatar Jonathan Mang 💡
Browse files

feat: added function `setdiff_all`

parent 32ee30e9
Pipeline #21770 passed with stages
in 20 minutes and 20 seconds
Package: DIZutils
Title: Utilities for 'DIZ' R Package Development
Version: 0.0.6.9002
Date: 2020-12-08
Version: 0.0.6.9003
Date: 2021-01-05
Authors@R:
c(person(given = "Jonathan M.",
family = "Mang",
......
......@@ -553,7 +553,7 @@ and each file should have at least the “copyright” line and a pointer to
where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2020 Universitätsklinikum Erlangen
Copyright (C) 2021 Universitätsklinikum Erlangen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -573,7 +573,7 @@ Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short notice like this
when it starts in an interactive mode:
DIZutils Copyright (C) 2020 Universitätsklinikum Erlangen
DIZutils Copyright (C) 2021 Universitätsklinikum Erlangen
This program comes with ABSOLUTELY NO WARRANTY; for details type 'show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'show c' for details.
......
......@@ -14,3 +14,4 @@ export(get_db_systems)
export(global_env_hack)
export(query_database)
export(set_env_vars)
export(setdiff_all)
#' @title Get the difference of two vectors in both directions.
#'
#' @description The base-R function `setdiff` is asymmetric meaning
#' `setdiff(vec1, vec2)` is not the same as `setdiff(vec2, vec1)`.
#' Only the first vector will be compared to the second vector and all
#' elements not contained in the second are in the resulting vector.
#' So if you also want in include all elements being in the second vector
#' but not in the first, you can use this function. In this case you are
#' searching for elements beeing in the union of both vectors but not
#' in the intersect of both vectors. This function is a symmetric function.
#' It doesn't matter in which order you input the vectors, the content
#' will be the same. Only the order of the elements inside the output
#' differs.
#'
#' @param vec1 First vector
#' @param vec2 Second vector
#' @return The difference between both vectors.
#'
#' @examples
#' \dontrun{
#' vec1 <- c(1,2,3,4)
#' vec2 <- c(3,4,5,6)
#' # setdiff(vec1, vec2) = c(1,2)
#' # setdiff(vec2, vec1) = c(5,6)
#' # setdiff_all(vec1, vec2) = c(1,2,5,6)
#' # setdiff_all(vec2, vec1) = c(5,6,1,2)
#' }
#'
#' @export
#'
setdiff_all <- function(vec1, vec2) {
return(setdiff(union(vec1, vec2), intersect(vec1, vec2)))
}
......@@ -34,7 +34,7 @@ my_desc$set_authors(c(
my_desc$del("Maintainer")
# Set the version
my_desc$set_version("0.0.6.9002")
my_desc$set_version("0.0.6.9003")
# The title of your package
my_desc$set(Title = "Utilities for 'DIZ' R Package Development")
......
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/setdiff_all.R
\name{setdiff_all}
\alias{setdiff_all}
\title{Get the difference of two vectors in both directions.}
\usage{
setdiff_all(vec1, vec2)
}
\arguments{
\item{vec1}{First vector}
\item{vec2}{Second vector}
}
\value{
The difference between both vectors.
}
\description{
The base-R function `setdiff` is asymmetric meaning
`setdiff(vec1, vec2)` is not the same as `setdiff(vec2, vec1)`.
Only the first vector will be compared to the second vector and all
elements not contained in the second are in the resulting vector.
So if you also want in include all elements being in the second vector
but not in the first, you can use this function. In this case you are
searching for elements beeing in the union of both vectors but not
in the intersect of both vectors. This function is a symmetric function.
It doesn't matter in which order you input the vectors, the content
will be the same. Only the order of the elements inside the output
differs.
}
\examples{
\dontrun{
vec1 <- c(1,2,3,4)
vec2 <- c(3,4,5,6)
# setdiff(vec1, vec2) = c(1,2)
# setdiff(vec2, vec1) = c(5,6)
# setdiff_all(vec1, vec2) = c(1,2,5,6)
# setdiff_all(vec2, vec1) = c(5,6,1,2)
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment