mergeVectors | R Documentation |
This function allows merging for multiple named vectors (each element needs to be named).
Basically, all elements carrying the same name across different input-vectors will be aligned in the same column of the output (input-vectors appear as lines).
If vectors are not given using a name (see first example below), they will be names 'x.1' etc (see argument namePrefix
).
mergeVectors(
...,
namePrefix = "x.",
NAto0 = FALSE,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
... |
all vectors that need to be merged |
namePrefix |
(character) prefix to numers used when vectors are not given with explicit names (second exammple) |
NAto0 |
(logical) optional replacemet of |
silent |
(logical) suppress messages |
debug |
(logical) additional messages for debugging |
callFrom |
(character) allow easier tracking of messages produced |
Note : The arguments 'namePrefix
', 'NAto0
', 'callFrom
' and 'silent
' must be given with full name to be recognized as such (and not get considered as vector for merging).
This function returns a matrix of merged values
merge
(for two data.frames)
x1 <- c(a=1, b=11, c=21)
x2 <- c(b=12, c=22, a=2)
x3 <- c(a=3, d=43)
mergeVectors(vect1=x1, vect2=x2, vect3=x3)
x4 <- 41:44 # no names - not conform for merging
mergeVectors(x1, x2, x3, x4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.