I am trying to index some components in a R formula such like
var<-c("x1", "x2", "x3")
for (i in var) as.formula(i/x4)
But it always come with an error:
Error in i/x4 : non-numeric argument to binary operator
May somebody know how to make it work? so that out with,
x1/x4, x2/x4, x3/x4
After reading OP's comments, changing answer to OP's needs
for (i in var) {
form <-sprintf("~ %s/ x4 ",i)
deltamethod(as.formula(form),...) #other arguments that you need to supply
}