Displaying 20 results from an estimated 10000 matches similar to: "Suppressing "creating new generic" and "expanding the signature" messages"
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2002 Aug 06
2
[ and setMethod conflict?
I noticed this oddity about [ and setMethod.
First, I define testFunc, which sorts a data frame by the first column and
returns the entries that aren't NAs, and testIt, which runs testFunc
repeatedly on a random large data frame, each time saving the return into a
dummy placeholder (for demonstration's sake).
> require(methods)
Loading required package: methods
[1] TRUE
> testFunc
2003 Jul 09
2
Packages, generics, S3 and S4
My question has two parts.
The first is with regard to the frame or environment in which generic
functions are defined in packages. It seems as though they are defined
(i.e. exist as objects) in frame 1, even when defined in a package.
The following is a short example:
setClass("track",representation(x="numeric",y="numeric"))
plotTrack <- function(x,y,...)
2002 May 29
1
warning message for setAs when using class AsIs
This seemed too advanced for r-help and is related to the recent discussion of
character vectors in dataframes.
Following Brian Ripley's most excellent advice, we are moving to a world in
which character vectors in dataframes are always of class AsIs. The cool way of
doing this seemed to be the following:
> cat(c("x", "y", "z"), file = "test.txt",
2002 May 22
1
signature match in setMethod (PR#1592)
Full_Name: Tim Keitt
Version: 1.5
OS: Linux
Submission from: (NULL) (128.227.201.237)
The function "setMethod" makes the following call to "insertMethod":
allMethods <- insertMethod(allMethods, signature, fnames[1:length(signature)],
asMethodDefinition(definition, signature))
If I understand insertMethod correctly, the third argument should be the names
of the
2003 May 30
2
Creating a vector class
I'm trying to create a package for working on orientation data, i.e.
data where the observations are 3D rotations.
There are several different representations of orientations in common
use: SO(3) matrices, Euler angles, unit quaternions, etc. One thing
I'd like is to make it convenient to work in any representation, and
have conversions to others done as needed.
I'm trying to do
2002 Jul 19
1
Rprof and setMethod conflict?
I noticed this oddity about R profiling and setMethod.
First, I "test out" Rprof.
> require(methods)
Loading required package: methods
[1] TRUE
>
> Rprof("test.out")
> data.frame("a")
X.a.
1 a
> Rprof(NULL)
So far, so good. Next, I define myClass.
> setClass("myClass", representation(mySlot = "numeric"))
[1]
2003 Nov 19
2
Was: setValidity and "initialize" method conflict ? [in R-help]
Hello,
Thomas Stabla (statho3@web.de) has already sent this
question to R-help, Wed, 12 Nov 2003 21:21:31 +0100,
but we are not sure whether we should better post this
mail to this audience than to R-help:
---------------------------------------------------------------------
We are using S4-classes and want to force a validity check
when an object is created.
How can this be done, when an
2003 May 21
1
callNextMethod
Hi,
I don't understand why this code doesn't work (f(b2)):
/////////////////
setClass("B0", representation(b0 = "numeric"))
setClass("B1", representation("B0", b1 = "character"))
setClass("B2", representation("B1", b2 = "logical"))
f <- function(x) class(x)
setMethod("f", "B0",
2002 Jul 01
1
SetGeneric and formula interfaces
Hi,
while playing with the `methods' package I was not able to find what the
recommended way of dealing with the following problem is.
Suppose there is a generic function `foo' and two functions `foo.default'
and `foo.formula', in the classical way:
foo <- function(y, ...) UseMethod("foo")
foo.default <- function(y, ...) {}
foo.formula <- function(formula,
2004 Jan 29
1
setMethodReplace.. Help!
Hi!
Trying to reproduce some examples from "Programming with Data" page 341.
Can not reproduce it neither on R1.8.1. nor R1.9.0devel?
library(methods)
setClass("track",representation(x="numeric",y="numeric"))
setMethod("["
,"track"
,function(x,...,drop=T){
track(x at x[...],y at y[...])
}
2003 Dec 02
1
setMethod("min", "myclass", ...)
Hello,
I have defined a new class
> setClass("myclass", representation(min = "numeric", max = "numeric"))
and want to write accessor functions, so that for
> foo = new("myclass", min = 0, max = 1)
> min(foo) # prints 0
> max(foo) # prints 1
At first i created a generic function for "min"
> setGeneric("min",
2002 May 08
1
Questions about S4 style methods and generics
I have some questions about S4 style methods and generics.
First of all, is there any way of using default values for arguments
in the generics/methods? My own experiments show that such arguments
are always ignored. The green book seems to be silent on this
matter.
The second question is about using a non-trivial function body for
generics. Page 351 of the green book gives an example of this
2002 Feb 19
1
library(methods): setMethod with "ANY" fails. (PR#1317)
Full_Name: Henrik Bengtsson
Version: R v1.4.1
OS: WinMe
Submission from: (NULL) (217.208.14.137)
Doing the following
library(methods)
setGeneric("foo", function(x) standardGeneric("foo"))
setMethod("foo", "ANY", function(x) cat(x))
fails with
Error in while (value[n] == "ANY") n <- n - 1 :
missing value where logical needed
It
2003 Sep 05
2
S4 Method Collisions with "[" (PR#4075)
Full_Name: Colin A. Smith
Version: 1.8.0
OS: Mac OS X 10.2.6
Submission from: (NULL) (216.102.90.18)
Both Biobase and my package annaffy use S4 classes to define methods for "[".
Both packages use the save image method of installation. (See annaffy 1.0.3 in
BioC CVS.)
Depending on how both packages are loaded, the Biobase definitions seem to be
getting masked out:
>
2003 Jun 10
1
c(...) and methods
I have been writing some S4 classes and have a problem about how I might
pass a signature to "c()".
Take the following example:
setClass("collection", representation("list", date="POSIXt"))
x <- new("collection", list(1,2,3), date=Sys.time())
y <- new("collection", list(4,5,6), date=Sys.time())
obviously, I can do c(x,y), but
2004 Jul 06
1
questions about setMethod("Arith", ...)
Hi,
we have some questions concerning the definition of new arithmetic methods.
In our package "distr" (on CRAN) we define some new arithmetic methods
for "+", "-", "*", "/".
After loading "distr" the corresponding arithmetic methods work. Now, if
we define a new
class and also a new method for one of the arithmetic methods
2003 May 23
3
Documenting S4 classes; debugging them
1. I'm putting together my first package that uses S4 classes and
objects. I'd like to document them, but I'm not sure what the
documentation should look like, and package.skeleton doesn't produce
any at all for the classes or methods.
Are there any good examples to follow?
2. How do I do the equivalent of debug(foo), when foo is an anonymous
function being used as a method?
2002 Dec 30
2
Writing packages with `methods' package
I'm trying to write a package which uses classes/methods as defined in the
`methods' package. I have a single .R file which defines the class and
various methods for that class. At the top of the file I have
require(methods)
and then
setClass("myclass", ...)
setGeneric("intersect")
setMethod("intersect", "myclass", function(x,y) ...)
I noticed
2004 Jun 07
1
Lazy Evaluation?
Hello,
I've stumbled upon following problem, when trying to overload the methods
for group Math for an S4-class which contains functions as slots.
setClass("NumFunction", representation = list(fun = "function"))
NumFunction <- function(f) new("NumFunction", fun = f)
square <- function(x) x^2
NF <- NumFunction(square)