Leonard Mada
2023-Mar-08 19:09 UTC
[R] Default Generic function for: args(name, default = TRUE)
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: https://github.com/discoleo/R/commits/master/Stat/Tools.Code.R
Bert Gunter
2023-Mar-08 19:24 UTC
[R] Default Generic function for: args(name, default = TRUE)
?.S3methods f <- function()(2)> length(.S3methods(f))[1] 0> length(.S3methods(print))[1] 206 There may be better ways, but this is what came to my mind. -- Bert On Wed, Mar 8, 2023 at 11:09?AM Leonard Mada via R-help < r-help at r-project.org> 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: > https://github.com/discoleo/R/commits/master/Stat/Tools.Code.R > > ______________________________________________ > R-help at r-project.org 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. >[[alternative HTML version deleted]]
Reasonably Related Threads
- Default Generic function for: args(name, default = TRUE)
- Tools to modify highlighted areas in pdf documents?
- Default Generic function for: args(name, default = TRUE)
- S3 methods in packages. Change in R 4.0.0?
- Error in rbind(info, getNamespaceInfo(env, "S3methods"))