search for: registers3method

Displaying 13 results from an estimated 13 matches for "registers3method".

2019 Oct 09
2
S3 lookup rules changed in R 3.6.1
...eric methods in environments that are not packages. I am trying to emulate the R package namespace mechanism by having a ?namespace? environment that defines generics and methods, but only exposes the generics themselves, not the methods. To make S3 lookup work when using the generics, I am using `registerS3method`. While this method itself has no extensive documentation, the documentation of `UseMethod` contains this relevant passage: > Namespaces can register methods for generic functions. To support this, > ?UseMethod? and ?NextMethod? search for methods in two places: in the > environment in wh...
2019 Oct 09
0
S3 lookup rules changed in R 3.6.1
...t > packages. I am trying to emulate the R package namespace mechanism by > having a > ?namespace? environment that defines generics and methods, but only exposes > the > generics themselves, not the methods. > > To make S3 lookup work when using the generics, I am using > `registerS3method`. > While this method itself has no extensive documentation, the documentation > of > `UseMethod` contains this relevant passage: > >> Namespaces can register methods for generic functions. To support this, >> ?UseMethod? and ?NextMethod? search for methods in two places: i...
2012 May 24
1
New S3 methods for optional package
...dency list of A is rather long, and most potential users of B will not be interested in package A and what it depends on. Unfortunately I struggle with doing this right. After asking on the list some time ago, I have listed A under Suggests, and have a .onLoad function in B with if (require(A)) registerS3methods(newMethodsMatrix, package = A, env = environment(B)) But starting with R 2.13 or R 2.14, R CMD check creates a note: "Package startup functions should not change the search path. See section 'Good practice' in ?.onAttach." I have understood that packages with notes can be upload...
2009 Sep 09
1
Monkey patching +.POSIXt
...t doesn't seem to work either, despite the documentation: "They do attempt to alter a copy registered as an S3 method if one is found." (perhaps there is a missing not there?) In desperation, I also tried the following internal, undocumented function, but it didn't help either: registerS3method("+", "POSIXt", lubridate::`+.POSIXt`) Any ideas? Thanks, Hadley -- http://had.co.nz/
2019 Sep 16
1
Error: package or namespace load failed for ‘utils
...cing R to not load any package at startup time (using > an Renviron file): ``` package <- "utils" lib.loc <- > "<fill this according to your R install>" ns <- > loadNamespace(package, lib.loc) ``` > The code path goes through > `registerS3methods(nsInfo$S3methods, package, env)` and > there to: > ``` if (methods::is(genfun, "genericFunction")) ``` > The evaluation of `methods::is` reaches the line > triggering the error as `.identC(class1, class2)` and > `.identC(class2, "ANY")` both...
2024 Mar 29
1
declare and validate options
...odymudskipper/opt I think we can do a bit better and that it's not necessarily so complex, here's a draft of possible design : We could have something like this in a package to register options along with an optional validator, triggered on `options(..)` (or a new function). # similar to registerS3method() : registerOption("mypkg.my_option1") registerOption("mypkg.my_option2", function(x) stopifnot(is.numeric(x)) # maybe a `default` arg too to avoid the .onLoad() gymnastics and invisible NULL options * validation is a breaking change so we'd have an environment variable to...
2019 Sep 08
6
Error: package or namespace load failed for ‘utils
Hi, When starting an embedded R I encounter the following issue under certain conditions: ``` Error: package or namespace load failed for ?utils? in if (.identC(class1, class2) || .identC(class2, "ANY")) TRUE else {: missing value where TRUE/FALSE needed ``` (more such errors for grDevices, graphics, and stats) And in the end: ``` Warning messages: 1: package ?utils? in
2024 Mar 29
1
declare and validate options
...can do a bit better and that it's not necessarily so complex, > here's a draft of possible design : > > We could have something like this in a package to register options along > with an optional validator, triggered on `options(..)` (or a new function). > > # similar to registerS3method() : > registerOption("mypkg.my_option1") > registerOption("mypkg.my_option2", function(x) stopifnot(is.numeric(x)) > # maybe a `default` arg too to avoid the .onLoad() gymnastics and invisible > NULL options > > * validation is a breaking change so we'd ha...
2024 Mar 29
1
declare and validate options
...39;s not necessarily so complex, > > here's a draft of possible design : > > > > We could have something like this in a package to register options along > > with an optional validator, triggered on `options(..)` (or a new > function). > > > > # similar to registerS3method() : > > registerOption("mypkg.my_option1") > > registerOption("mypkg.my_option2", function(x) stopifnot(is.numeric(x)) > > # maybe a `default` arg too to avoid the .onLoad() gymnastics and > invisible > > NULL options > > > > * validation i...
2015 Dec 22
0
unloadNamespace() does not address unevaluated promises in the S3 Methods Table
...> lazy-load database '{sic}/testUnload/R/testUnload.rdb' is corrupt #> In addition: Warning message: #> In get(method, envir = home) : internal error -3 in R_decompress1 #> Error: package or namespace load failed for ?testUnload? Upon investigation this is because the code in registerS3Methods creates a promise using 'delayedAssign' for 'print.object' function in the '.__S3MethodsTable__.' environment within the base environment (which is where the 'print' generic is defined). (see lines 1387-1489 in src/library/base/R/namespace.R). When the second insta...
2010 Feb 08
2
Error on start R in server
...99 then 97 Warning: stack imbalance in '<-', 84 then 85 Warning: stack imbalance in '{', 82 then 84 Warning: stack imbalance in 'if', 80 then 82 Traceback: 1: .getClassFromCache(Class, where) 2: getClassDef(cl) 3: methods:::is(genfun, "genericFunction") 4: registerS3methods(nsInfo$S3methods, package, env) 5: loadNamespace(package, c(which.lib.loc, lib.loc), keep.source = keep.source) 6: doTryCatch(return(expr), name, parentenv, handler) 7: tryCatchOne(expr, names, parentenv, handlers[[1L]]) 8: tryCatchList(expr, classes, parentenv, handlers) 9: tryCatch(expr, er...
2006 Apr 24
0
R 2.3.0 is released
...n the model frame that will be used are numeric (they previously also checked columns which were part of negative terms in the formula). o Misuse of $ in apply could corrupt memory. (PR#8718) o apply() could fail if the function returned NULL (e.g. if there was a single row). o registerS3method() failed due to a typo. (It was almost never used.) o Registering an S3 method for an S3 generic in another package that was converted to an S4 generic in the same package as the S3 method, registered the method in the wrong place. o Recall() used lookup for the function in use and so...
2006 Apr 24
0
R 2.3.0 is released
...n the model frame that will be used are numeric (they previously also checked columns which were part of negative terms in the formula). o Misuse of $ in apply could corrupt memory. (PR#8718) o apply() could fail if the function returned NULL (e.g. if there was a single row). o registerS3method() failed due to a typo. (It was almost never used.) o Registering an S3 method for an S3 generic in another package that was converted to an S4 generic in the same package as the S3 method, registered the method in the wrong place. o Recall() used lookup for the function in use and so...