Description Usage Arguments Details Value Author(s) See Also Examples
vswitch
returns a value with the same shape as x
which is filled with elements selected from...
depending on the values of x
.
1 2 3 4 5 6 7 |
x |
|
... |
vectors. If |
The class of the return value depends on the class(es) of ...
. All elements in ...
are coerced to the same class with the usual rules.
If x
is character
or factor
then ...
should be named. All values of x
should correspond to names in ...
.
If x
is integer
then names in ...
will be ignored with a warning. Furthermore if values of x
are smaller than 1
or greater than the number of elements in ...
an error will be produced.
NA
values in x
return NA
.
A vector of the same length as x
and a class depending on the result of the coercion of all the elements in ...
to the same class.
Antoine Filipovic Pierucci
1 2 3 4 5 6 7 8 9 10 11 12 13 | a <- 1:5
b <- 11:15
c <- 21:25
condChar <- c('d', 'e', 'f', 'd', 'e')
condInt <- c(1, 2, 3, 1, 2)
condFac <- as.factor(condChar)
condMissing <- c(1, NA, 3, NA, 2)
vswitch(x = condChar, d = a, e = b, f = c)
vswitch(x = condInt, a, b, c)
vswitch(x = condFac, d = a, e = b, f = c)
vswitch(x = condMissing, a, b, c)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.