https://github.com/cran/simecol
Raw File
Tip revision: 27972f79606ed158414d982ce17b7f8dbe5bb6e9 authored by Thomas Petzoldt on 07 October 2021, 05:40:02 UTC
version 0.8-14
Tip revision: 27972f7
mixNamedVec.R
mixNamedVec <-
function(x, y, resolve.conflicts = c("x", "y"), warn = TRUE) {
  if (!(is.vector(x) & is.vector(y))) stop("x and y must be vectors")
  resolve.conflicts <- match.arg(resolve.conflicts)
  
  xnames <- names(x)
  ynames <- names(y)
  
  duplicates <- xnames[xnames %in% ynames]
  
  if ((warn) & !is.null(duplicates)) 
    warning(paste("name duplicates found:", paste(dQuote(duplicates), collapse=", ")))
  if (resolve.conflicts == "x")
    return(c(y[!(ynames %in% xnames)], x))
  if (resolve.conflicts == "y")
    return(c(x[!(xnames %in% ynames)], y))
}

back to top