I have a long list of covariates that I want to store as a string in order to work with it more conveniently in several functions.
I think the issue is related to this question, but I can't apply it to cases different to regression formulas.
xvar <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
with(iris, iris[order(Sepal.Length, Sepal.Width,
Petal.Length, Petal.Width), ]) # working
with(iris, iris[order(xvar), ]) # not working
Or an other case
with(iris, ave(Sepal.Length, Sepal.Width,
Petal.Length, Petal.Width)) # working
with(iris, ave(xvar)) # not working
with(iris, ave(noquote(paste(xvar, collapse = ", ")))) # not working as well
Especially the paste-version I don't understand why it's not working, though it yields exactly the same string as the one in the parentheses:
> noquote(paste(xvar, collapse = ", "))
[1] Sepal.Length, Sepal.Width, Petal.Length, Petal.Width
What am I missing?