I am using xyplot with inputs Y1 + Y2 ~ X.
I would like to pass Y1 + Y2 as a list, rather than two explicit variables.
That way, I can write a generic xyplot function and pass it different values for a series of Ys.
Is that possible?
I am using xyplot with inputs Y1 + Y2 ~ X . I would
Share
One strategy is to first paste together a character string representation of the formula, and then convert it to an object of class
"formula", usingas.formula(). Here’s an example using themtcarsdataframe that ships with base R.