Re: [R] Dispatching on 2 arguments?

2021-11-06 Thread Andrew Simmons
If you want to use the 'methods' package, you could do something like: replace <- function (p1, p2, ...) { stop(gettextf("cannot 'replace' with arguments of class %s and %s", sQuote(class(p1)[1L]), sQuote(class(p2)[1L]))) } methods::setGeneric("replace") methods::setMethod("replac

[R] Dispatching on 2 arguments?

2021-11-06 Thread Leonard Mada via R-help
Dear List-members, I would like to experiment with dispatching on 2 arguments and have a few questions. p1 = data.frame(x=1:3, coeff=1) class(p1) = c("pm", class(p1)); I want to replace variables in a polynomial with either: another polynomial, or another variable (character) or with a spec