R - how to pass formula to a with(df, glm(y ~ x)) construction inside a function
问题 I'm using the mice package in R to multiply-impute some missing data. I need to be able to specify a formula that is passed to a with(df, glm(y ~ x)) construction inside of a function. This with() construction is the format used by the mice package to fit the regression model separately within each of the imputed datasets. However, I cannot figure out the scoping problems preventing me from successfully passing the formula as an argument. Here is a reproducible example: library(mice) data