Dear Gregg,
Thank you for the fast response.
I believe though that isGeneric works only for S4-functions:
isGeneric("plot")
# FALSE
I still try to get it to work.
Sincerely,
Leonard
On 3/8/2023 9:13 PM, Gregg Powell wrote:
Yes, there is a way to check if a function is generic. You can use the
isGeneric function to check if a function is generic. Here's an updated version
of the args function that includes a check for generic functions:
args = function(name, default = TRUE) {
if(default && isGeneric(name)) {
fn = paste0(as.character(name), ".default")
name = fn
}
.Internal(args(name))
}
r/
Gregg
------- Original Message -------
On Wednesday, March 8th, 2023 at 12:09 PM, Leonard Mada via R-help
<[email protected]> wrote:
Dear R-Users,
I want to change the args() function to return by default the arguments
of the default generic function:
args = function(name, default = TRUE) {
# TODO: && is.function.generic();
if(default) {
fn = match.call()[[2]];
fn = paste0(as.character(fn), ".default");
name = fn;
}
.Internal(args(name));
}
Is there a nice way to find out if a function is generic: something like
is.function.generic()?
Many thanks,
Leonard
=======
Note:
- the latest version of this code will be on GitHub: [edited]
https://github.com/discoleo/R/blob/master/Stat/Tools.Code.R
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://eu01.z.antigena.com/l/CoS9jxWcs77ZH1EdYpfdt4f1PgsZsEHB9bGmOMbk~shS17K1eTNQZGNHQeCHXm_3FeDw2W64pxRnUN0qYZCeC-KYHDkXzka9~lEVxf9mq1jf24zCj~A96_OSrQj~-IjJgb0J9~DKPpwYsqrK9jJHy9jPj6T3V2M8SAwxFZzj
PLEASE do read the posting guide
https://eu01.z.antigena.com/l/CoS9jwics77ZHse0yVQ6JzRj1U7ZoE-xBthsLCBb5dXiWzcWWdMG5w6w0ko3hHpOaKJLXU-CYJO0bkWf-_eiJLh3FOnfRi22P4jyYsHId9eMpOYB7kA9rQXziAjRycjqgrVw9~DKHfurjKs2zz-nxsjOrlIOuYLYHtTk0XXQ
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.