similar to: Fwd: passing a modified argument to an S3 method

Displaying 20 results from an estimated 20000 matches similar to: "Fwd: passing a modified argument to an S3 method"

2024 Apr 20
2
passing a modified argument to an S3 method
I do not understand what your goal is here (more context may be helpful, perhaps to others rather than me). So I doubt this is what you want, but here is a guess -- no need to respond if it is unhelpful: ## test.default returns NULL if object "y" not found in **calling environment and enclosures**; ## otherwise y. test <- function(x){ UseMethod("test") } test.default
2024 Apr 19
2
passing a modified argument to an S3 method
Is there a way to pass a modified argument from an S3 generic to a method? Here's a non-working example that I want to return "abcd". test <- function(x, y = NULL){ y <- "abcd" UseMethod("test") } test.default <- function(x, y = NULL) y test(x = 3) Is that possible? I've looked around a lot, but can't find any examples or
2010 Jun 09
0
Argument mismatches in S3 generic and method
The way R treats the first argument to an S3 method which uses a different name for the argument than the generic depends on whether there is a ... in the argument list. If there is is no ellipsis then the call cannot tag the argument with either name but an untagged first argument works: > zNoDots <- function(x) UseMethod("zNoDots") > zNoDots.foo <- function(fooObject)
2012 Feb 09
1
passing an extra argument to an S3 generic
I'm trying to write some functions extending influence measures to multivariate linear models and also allow subsets of size m>=1 to be considered for deletion diagnostics. I'd like these to work roughly parallel to those functions for the univariate lm where only single case deletion (m=1) diagnostics are considered. Corresponding to stats::hatvalues.lm, the S3 method for class
2006 Mar 15
1
Additional arguments in S3 method produces a warning
Hello, I just notice this: > x <- c(1:4,0:5, 4, 11) > library(pastecs) Loading required package: boot > tp <- turnpoints(x) > extract(tp, no.tp = FALSE, peak = TRUE, pit = FALSE) [1] FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE Warning message: arguments after the first two are ignored in: UseMethod("extract", e, n, ...) >
2009 Oct 20
1
Suggestion for exception handling: More informative error message for "no applicable method..." (S3)
I'd like to suggest that whenever there is no S3 method implementation available for a particular class, that the error message would also report the class structure of the object dispatched on. Example: foo <- function(...) UseMethod("foo") foo.ClassA <- function(object, ...) { cat("foo() for ClassA called.\n") } > foo(structure(1, class="ClassA"))
2017 Sep 11
0
show 0 at y axis in xyplot lattice
Not reproducible, as we have neither "example.csv" nor "Date" . Cheers, Bert Bert Gunter "The trouble with having an open mind is that people keep coming along and sticking things into it." -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip ) On Mon, Sep 11, 2017 at 2:38 PM, Maria Lathouri <mlathouri at yahoo.gr> wrote: > Dear
2003 Jul 03
1
S4 method and S3 method with same name: potentially dangerous?
Dear list, yet another question on S4 method behaviour or rather its side effects: Consider the following example (see below) where a new S4 method 'predict' is defined which by doing so makes 'predict' a S4 standardGeneric. It works and simple test examples run but I'm cautious whether this is a 'silly' thing to do. Is this a dangerous thing to do, already known to
2008 Apr 22
0
S3 method despatch (changed between 2.6.2 and 2.7.0 RC?)
Dear developers: I have observed a change in the behaviour of S3 method despatch (as I guess related to namespaces) between 2.6.2 and yesterday's 2.7.0 RC and would be grateful if you could comment on that: the 'Axis' function in the 'graphics' namespace calls UseMethod("Axis",x), internally to despatch on the S3 Axis method depending on the type of the argument.
2019 Oct 09
0
S3 lookup rules changed in R 3.6.1
On 09/10/2019 3:22 p.m., Konrad Rudolph wrote: > tl;dr: S3 lookup no longer works in custom non-namespace environments as of > R 3.6.1. Is this a bug? I don't know whether this was intentional or not, but a binary search through the svn commits finds that the errors started in this one: ------------------------------------------------------------------------ r75127 | hornik |
2010 Sep 07
1
Dispatch method on S3 or S4 class
Hello, I've been attempting to make a generic method that dispatches on the first argument, which can be either an S3 or an S4 class. This is as far as I've gotten. Any suggestions about what to try next ? library(aroma.affymetrix) library(GenomicRanges) setGeneric("analyse", function(x, y, ...) standardGeneric("analyse")) setMethodS3("analyse",
2014 Mar 04
1
How to import S3 method
Dear Helpers, I wanted to import an S3 method from package glmnet to my own R package. Specifically, I tried the following: plot.glmreg=function(x, xvar=c("norm","lambda","dev"),label=FALSE,shade=TRUE, ...) UseMethod("glmnet") I got the following message when installing my package: Error : object 'plot.glmnet' is not exported by
2016 Apr 18
3
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Scenario: An S3 method is declared for an S4 base class but called for an instance of a derived class. Steps to reproduce: > Rscript -e "test <- function(x) UseMethod('test', x); test.Matrix <- function(x) 'Hi'; MatrixDispatchTest::test(Matrix::Matrix())" Error in UseMethod("test", x) : no applicable method for 'test' applied to an
2016 Apr 19
0
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Right, the methods package is not attached by default when running R with Rscript. We should probably remove that special case, as it mostly just leads to confusion, but that won't happen immediately. For now, the S4_extends() should probably throw an error when the methods namespace is not loaded. And the check should be changed to directly check whether R_MethodsNamespace has been set to
2016 Apr 19
0
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Not sure why R_has_methods_attached() exists. Maybe Martin could shed some light on that. On Mon, Apr 18, 2016 at 11:50 PM, Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> wrote: > Thanks for looking into it, your approach sounds good to me. See also > R_has_methods_attached() >
2011 Feb 03
1
S3 method for S4 object
I am trying to extend an S3 method to work with an S4 object as well as the S3 objects it works with, but UseMethod does not seem to recognize the S4 class and dispatches to the default method. Is this to be expected or should I be looking for an error in my code? If it is not an error in my code, is there an easy way to do this, or do I have to convert the generic to S4 and then make those
2017 Sep 11
2
Σχετ: show 0 at y axis in xyplot lattice
Dear Bert and all, I am really sorry. This is the full code: dat<-read.csv("example.csv")attach(dat) sdate<-as.Date(Date, format="%Y-%m-%d") #change the colour of the strip background my.settings <- canonical.theme(color=FALSE) my.settings[['strip.background']]$col <- "blue" dat_key <- list(space="right", ??????????????? lines =
2016 Apr 19
0
S3 dispatch for S4 subclasses only works if variable "extends" is accessible from global environment
Right, R_has_methods_attached() uses that. Probably not the right check, since it refers to S4 dispatch, while S4_extends() is used by S3 dispatch. Perhaps S4_extends() should force load the methods package? The above example works after fixing the check to ensure that R_MethodsNamespace is not R_GlobalEnv, but one could load a serialized S4 object and expect S3 dispatch to work with Rscript. On
2008 Apr 28
1
variable names when using S3 methods
I'm seeing some funny behavior when using methods (the older S3 type) and having variables that start with the same letter. I have a vague recollection of reading something about this once but now can't seem to find anything in the documentation. Any explanation, or a link to the proper documentation, if it does exist, would be appreciated. Thanks, Aaron Rendahl University of
2012 Jul 30
1
confusion over S3/S4 importing
Can anyone help me figure out the right way to import a method that is defined as S3 in one package and S4 in another? Specifically: profile() is defined as an S3 method in the stats package: function (fitted, ...) UseMethod("profile") <bytecode: 0xa4cd6e8> <environment: namespace:stats> In stats4 it is defined as an S4 method: stats4:::profile standardGeneric for