How would I convert a column of R formulas to include the data frame specification? For example I have a column of hundreds of formulas, but they don’t contain any data frame spec, such as:
365/(x/y)
365/(x/(y + z))
365/(x/ (y - z))
c + d + e + f
and I would like to convert the whole column to look like:
365/(r$x/r$y)
365/(r$x/(r$y + r$z))
365/(r$x/ (r$y - r$z))
r$c + r$d + r$e + r$f
so I basically want to add a prefix(r$) to each text group separated by operators. is this possible to do in R?
A much better approach is to supply the data frame directly as e.g.
as many modelling function support a
data=argument.Alternatively, you can use the
withandwithinfunctionswhich provide access to the components of the data frame
myframewithout requiring the prefix.