Is there a way to turn a call into a vector in R?
I have a call that I got from completing an ANOVA
> final.test.result.type
aov(formula = Value ~ STATION, data = df)
I want to turn the call "final.test.result.type" into a vector that contains a row with the 'call' as a written statement
I would do this:
# fake data
set.seed(123)
df <- data.frame(
Value = rnorm(10),
STATION = rep(c("A", "B"), each = 5)
)
# the function
final.test.result.type <- aov(Value ~ STATION, data = df)
call_vector <- deparse(final.test.result.type$call)
Note the "[1]" in the output, it is a unidimensional vector
> call_vector
[1] "aov(formula = Value ~ STATION, data = df)"