search for: usemethod

Displaying 20 results from an estimated 619 matches for "usemethod".

2004 Nov 15
1
UseMethod call with no arguments
Dear R developers, I will ask a very straightforward question concerning UseMethod's future, because people depending on my code wonder what will happen to it next. In R v2.0.1 NEWS it says o The undocumented use of UseMethod() with no argument is now formally deprecated. and in the R v2.0.1 help(UseMethod) it says 'UseMethod' accepts a call with no argume...
1999 Apr 14
5
R's UseMethod() does not dispatch on changed class() (PR#167)
(opening new bug report thread, on suggestion of BDR ..) I said on vaguely related topic: MM> There's another long-standing MM> UseMethod / NextMethod / Dispatch problem that I've never traced/solved.. MM> MM> Look at the $RHOME/tests/mode-methods.R file ! Peter Dalgaard already remarked : PD> ..i.e. this: PD> abc <- function(x, ...) { PD> if (is.null(class(x))) class(x) <- data.class(x) PD&...
2012 Dec 04
1
inconsistencies between ?class and ?UseMethod
...inconsistent description of class(): Found in ?class: If the object does not have a class attribute, it has an implicit class, ?"matrix"?, ?"array"? or the result of ?mode(x)? (except that integer vectors have implicit class ?"integer"?). Found in ?UseMethod: Matrices and arrays have class ?"matrix"? or?"array"? followed by the class of the underlying vector. Most vectors have class the result of ?mode(x)?, except that integer vectors have class ?c("integer", "numeric")? and real ve...
2001 Nov 16
1
UseMethod() fails to (PR#1176)
match the argument 'x' if there is another argument with prefix 'x' Full_Name: Henrik Bengtsson Version: 1.3.1 OS: Sun Solaris 8 Submission from: (NULL) (130.235.3.49) I ran into a strange problem with UseMethod(). Run the following code: foo.Bar <- function(this, x=0, xidx=0) { cat("In foo.Bar(): ", this, ", x=", x, ", xidx=", xidx, ".\n", sep=""); } foo.default <- function(x, ...) { str("Error: No default function found!"); } foo &l...
2006 May 19
1
UseMethod infelicity
If I do > example(lm) ... > mycoef <- function(object, ...) UseMethod("coef", object) > mycoef(lm.D9) Error in mycoef(lm.D9) : no applicable method for "coef" which is pretty surprising, as coef has a default method. After a bit of digging, this comes from do_usemethod having defenv = environment where the generic was defined */...
2005 Apr 10
2
the difference between UseMethod and NextMehod?
hi,usRs,i am studing the R programming,but i can not get the point abut the difference between UseMethod and NextMehod.i have read the manual and try to find the solutin from internet,but i still not master it well.so anyone can give me a guide?it will be better to show some examples . thank you !
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")) foo() for ClassA called. Now: > foo(NULL) Error in UseMethod("foo") : no applicable method for "foo" > foo(Sys.time(...
2003 Jan 20
0
UseMethod change; isas-tests; all.equal
...s demos.Rout had what looks like an unwanted piece of output, printing an attribute "legend" after doing symnum(summary(detg.mod, correlation = TRUE)$corr) There are a slew of differences in the isas-tests output. There are two issues here, one a real inconsistency from the change in UseMethod, the other a problem with the isas-tests. 1. Part or all of the changes come from a real example of the behavior I optimistically called "bizarre": having a foo.numeric that you DON'T want to be dispatched on numeric objects. The example is all.equal.numeric (and .list, .character)...
2001 Nov 16
0
Best/safest way to use UseMethod()?
I raised the questions below a couple of months ago by sending it to the developers mailing list, but I don't know if it got through since no one replied to it. Looking at the [R] distribution, the UseMethod() is used in the following way: alias <- function(object, ...) UseMethod("alias") or barplot <- function(height, ...) UseMethod("barplot") What I would like to point out here is that there is a first argument ('object' and 'height'). This might...
2005 Oct 31
0
Minor typos with UseMethod docs (PR#8269)
Full_Name: Mike Kay Version: R-patched OS: Linux Submission from: (NULL) (137.75.70.37) Hi, The following patch cleans up some grammar in the docs for UseMethod (library/base/help/UseMethod) -mike --- UseMethod 2005-09-28 20:06:39.000000000 +0000 +++ /tmp/UseMethod 2005-10-31 21:21:05.534708720 +0000 @@ -5,7 +5,7 @@ Description: R possesses a simple generic function mechanism which can be used - for an object-oriented style of programm...
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 object of class "lsyMatrix" Calls: <Anonymous> 1: MatrixDispatchTest::...
2003 Mar 26
0
Rprof/UseMethod
I'm having difficulty with Rprof. I have a documentation example test.qss that runs fine without profiling, but under Rprof, > Rprof() > source("test.qss") Error in standardGeneric("model.matrix") : UseMethod used in an inappropriate fashion Luke wrote about a similar circumstance last summer: # From: Luke Tierney (luke@stat.umn.edu) # Date: Fri Jul 19 2002 - 16:03:17 EDT # # * In reply to: Bartz, Kevin: "[R] Rprof and setMethod conflict?" # # This sounds like a bug in the useme...
1999 Jul 15
2
R: UseMethod with primitives?
Hello, is the following somehow possible with Mod() being a primitive: "Mod" <- function(x) UseMethod("Mod") "Mod.default" <- function(x) { .Primitive("Mod") ### I know it?s wrong. How can I access the original Mod ? } Thanks for help M. Eger -- +------------------------------------------------------- | Marcus Eger | Philipps Universitaet Marburg | Fachberei...
2005 Oct 18
3
Finding code for R functions
...interested in finding the code for the "prcomp" function. I know that typing the function name without parenthesis will lead to the code (or to a .Internal or .FORTRAN or .C call). However, I don't really understand what is going on. For example, typing "mean" gives a "UseMethod" response, while typing "mean.default" give the actual code: > mean function (x, ...) UseMethod("mean") <environment: namespace:base> > mean.default function (x, trim = 0, na.rm = FALSE, ...) ---SNIP--- } <environment: namespace:base> Why is this? Wha...
2010 Dec 22
1
forcing evaluation of a char string argument
I'm trying to make a function to turn a regular function into an S3 generic one. I want myMethod to be: function(x,...) UseMethod("myMethod") But I keep getting: function(x,...) UseMethod(func) Here's the function: toGeneric<-function(func) { env<-environment(get(func)) # default method of new generic = the original function assign(paste(func,".default",sep=""),get(func),po...
2023 Oct 20
0
UseMethod forwarding of local variables
UseMethod has since the beginning had the 'feature' that local variables in the generic are added to the environment in which the method body is evaluated. This is documented in ?UseMethod and R-lang.texi, but use of this 'feature' has been explicitly discouraged in R-lang.texi for many years...
2003 Jan 21
0
UseMethod; all.equal; isas-tests
1. UseMethod (via usemethod in objects.c) now uses the definition of class() to dispatch, with the methods package attached (dataClass(x)) and without (attr(x, "class")). Packages using a construction of the form if(is.null(class(x))) class(x) <- data.class(x) UseMethod("foo") should n...
2004 Oct 28
1
Internal function isUME() in findGeneric() is wrong (PR#7320)
...an Version: 2.0 OS: Linux Submission from: (NULL) (132.200.32.34) The function findGeneric() in the utils namespace contains this internal function: isUME <- function(e) { if (is.call(e) && (is.name(e[[1]]) || is.character(e[[1]]))) { switch(as.character(e[[1]]), UseMethod = as.character(e[[2]]), "{" = isUMEbrace(e), "if" = isUMEif(e), "") } else "" } This fails if the generic called UseMethod() without an argument, which is perfectly legal. Changing it to this seems to work: isUME <...
2004 Sep 27
2
Getting code for functions
...ious terms, but to no avail. I am using R1.9.1 on a windows machine One of the great advantages of R (to me, anyway) is being able to see the code for a function , e.g. by typing sd one sees the code for getting a standard deviation. However, for many functions this only provides info. including UseMethod, eg. typing mosaicplot yields function (x, ...) UseMethod("mosaicplot") <environment: namespace:graphics> How can I see the code for such functions? Thanks in advance as always Peter Peter L. Flom, PhD Assistant Director, Statistics and Data Analysis Core Center for Drug Us...
2006 Apr 14
3
The object argument of NextMethod.
My question is when the object argument of NexthMethod be used? In the following example, weather object argument is used will not affects the result. ### foo=function(x) {UseMethod("foo")} foo.cls1=function(x) { x=x+1;class(x)<-"ncls" NextMethod() } foo.ncls=function(x) { cat("ncls\n") } foo.cls2=function(x) { cat("cls2\n");print(x) } a=1;class(a)=c("cls1","cls2") > foo(a) cls2 [1] 2 attr(,"class&...