As a rule, it is better to avoid working with lines representing the code where possible - this prevents errors that are difficult to debug, and aesthetically much more elegant. This problem turns out to be pretty easy to solve if you use the do.call
and setNames
:
var <- "x1" cmp <- do.call(mcp, setNames(list("Tukey"), var)) glht(fm1, linfct = cmp)
You cannot use substitute
here because it does not allow changing function parameter names. I have an intuition why this is reasonable, but not enough to explain this: /
If you are the author of the package, itβs nice to provide an alternative version of functions that use unusual syntax so that you can get them programmatically without jumping over hoops.
source share