Description Usage Arguments Author(s) Examples
Concatenate vectors after converting to character. Unpack a vector v
as a string of concatenated values, separated by sep "+". Userful for as.formula.
1 | unpack(v, separator = " + ")
|
v |
one or more |
separator |
a character string to separate the terms. Default: the character is "+" |
The implementation of fonction formula by Pierre Lejeail, Jean-Luc Yonwe & Maite Garcia (2016).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # define vector v
v <- c("Hello", "world!", "Vector", "unpacked!")
unpack(v, separator=" ")
# Example with Iris
data(iris)
v <- colnames(iris)[-5]
# return in shape for as.formula without interactions
f1 <- paste("Species ~", unpack(v, "+"))
# return in shape for as.formula with interactions
f2 <- paste("Species ~", unpack(v, "*"))
library(MASS)
# lda without interactions
lda(as.formula(f1), data=iris, family="binomial")
# lda with interactions
lda(as.formula(f2), data=iris, family="binomial")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.