Description Usage Arguments Value Author(s) See Also Examples
The function mixes two named vectors. The resulting vectors contains all elements with unique name and only one of the two versions of the elements which have the same name in both vectors.
1 | mixNamedVec(x, y, resolve.conflicts = c("x", "y"), warn = TRUE)
|
x |
first named vector, |
y |
second named vector, |
resolve.conflicts |
name of the vector from which all elements are taken, |
warn |
an indicator if a warning should be given if elements are not unique. This argument should usually set to FALSE, but the default is TRUE to be on the safe side. |
a vector with all elements from one vector and only these elements of the second, that have a unique name not contained in the other vector.
Thomas Petzoldt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | x <- c(a=1, b=2, c=3)
y <- c(a=1, b=3, d=3)
mixNamedVec(x, y)
mixNamedVec(x, y, resolve.conflicts="x")
mixNamedVec(x, y, resolve.conflicts="x", warn=FALSE)
mixNamedVec(x, y, resolve.conflicts="y", warn=FALSE)
## without names, returns vector named in "resolve conflicts"
x <- as.vector(x)
y <- as.vector(y)
mixNamedVec(x, y)
mixNamedVec(x, y, resolve.conflicts="y")
## names partly
x <- c(4, a=1, b=2, c=3, 4, 9)
y <- c(a=1, 6, b=3, d=3, 8)
mixNamedVec(x, y)
mixNamedVec(x, y, resolve.conflicts="y")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.