I want to pass a comma separated vector i've manually created directly to a glm model. The model requires predictors to be separated by a plus sign +
so I was wondering if there was a clever way to replace the ,
s with +
s as I pass the vectors to the model?
For example, say I have these two vectors:
fruits <- c('apples', 'bananas', 'pears', 'apricots')
colors <- c('blue', 'red', 'orange', 'purple')
At the moment, i'm just copying the predictors and adding in +
signs manually. E.g.
glm(dependent_var ~ apples + bananas + pears + apricots + blue + red + orange + purple, data = df, family = "binomial")
What i'd love to do is find a way to make this less manual. E.g. is there a way I can basically just copy in the vector names themselves? Something like
glm(dependent_var ~ fruits + colors, data = df, family = "binomial")