'R pasting character vector within emmeans
I have a fairly large list of variables that I want to collapse across for estimating marginal means via emmeans. I'd like to list these out once to keep the analytic code more clean. Here's a sample:
covs_mrg <- c("male", "race4", "unemployable")
Then i'd like to just be able to refer to covs_mrg where it says nuisance = like:
mrg_mns <- emmeans(emp6mos_out, ~ tx, type='response', nuisance = c("male", "race4", "unemployable")
I've tried using the following, but emmeans doesn't seem to recognize it:
covs_mrg <- paste("c(", paste(shQuote(c("male", "race4", "unemployable") ), collapse=", "),")")
I've even tried wrapping the result within as.formula(), but that didn't seem to work either. Any help is appreciated!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
