unpack: Unpack Vector(s)

Description Usage Arguments Author(s) Examples

Description

Concatenate vectors after converting to character. Unpack a vector v as a string of concatenated values, separated by sep "+". Userful for as.formula.

Usage

1
unpack(v, separator = " + ")

Arguments

v

one or more R objects, to be converted to character vector(s)

separator

a character string to separate the terms. Default: the character is "+"

Author(s)

The implementation of fonction formula by Pierre Lejeail, Jean-Luc Yonwe & Maite Garcia (2016).

Examples

 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")

plejeail/Wrapper documentation built on May 5, 2019, 5:54 p.m.