Displaying 20 results from an estimated 8000 matches similar to: "[ and setMethod conflict?"
2002 Aug 07
0
FW: [R] [ and setMethod conflict?
John Chambers suggested that I forward this thread (first posted to r-help)
along to r-devel...
Thanks,
Kevin
-----Original Message-----
From: John Chambers [mailto:jmc@research.bell-labs.com]
Sent: Tuesday, August 06, 2002 6:31 PM
To: Bartz, Kevin
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] [ and setMethod conflict?
Definitely something funny going on, but perhaps a little less sweeping
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 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 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
2003 Aug 21
2
efficiency and memory use of S4 data objects
I do lots of analyses on large microarray data sets so memory use and speed
and both important issues for me. I have been trying to estimate the
overheads associated with using formal S4 data objects instead of ordinary
lists for large data objects. In some simple experiments (using R 1.7.1 in
Windows 2000) with large but simple objects it seems that giving a data
object a formal class
2002 Aug 26
1
Rprof and setMethod conflict (PR#1949)
Full_Name: Kevin C. Bartz
Version: 1.5.1
OS: Solaris 2.6
Submission from: (NULL) (192.223.226.5)
A while ago, 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
2004 Jul 28
3
as(obj,"matrix")
Hi!
Here a simple example.
setClass("myclass"
,representation(info="character")
,contains="matrix"
)
rownames(dd)<-c("a","b")
tt<-new("myclass",dd)
#the source of pain.
as(tt,"matrix")<-matrix(1,3,3)
Error: length of dimnames [1] not equal to array extent
Is there a different way to do what I would like to do (I
2004 Jul 28
3
as(obj,"matrix")
Hi!
Here a simple example.
setClass("myclass"
,representation(info="character")
,contains="matrix"
)
rownames(dd)<-c("a","b")
tt<-new("myclass",dd)
#the source of pain.
as(tt,"matrix")<-matrix(1,3,3)
Error: length of dimnames [1] not equal to array extent
Is there a different way to do what I would like to do (I
2002 Jul 15
1
Suppressing "creating new generic" and "expanding the signature" messages
Hi all,
I am building a R package which defines a class. I have overloaded methods
for this class using setMethod, and now, when I require my package, I get
diagnostic messages.
setMethod("[", signature(x = "portfolio"),
function(x, i, j, ...) {
# ...
})
> require(portfolio)
Loading required package: portfolio
[... loading other required packages ...]
Creating a new
2004 Sep 07
2
as(object,"list") as(object,"matrix") differences?
Hello!
as(object,"list") and as(object,"matrix") behave quite differently if it comes to their attributes.
I define two classes. One of them "contains" a "list" the other a "matrix"
setClass("myclass"
,representation(info="character")
,contains="matrix"
)
setClass("mylist"
2011 Oct 22
1
setMethod "[" - extract by names within Slot
Hi R-helper!
I have problem with setMethods for "[". Here is example :
setClass("myClass", representation(ID.r = "numeric", ID.c = "character", DAT = "matrix"))
to.myClass <- function(ID.r, ID.c, DAT) {
out <- new("myClass", ID.r = ID.r, ID.c = ID.c, DAT = DAT)
return(out)
}
setMethod("[",
2008 Mar 20
1
setMethod for "["
Hi R-Help,
Please consider the following simple case: I have a class like
setClass("myClass",
representation(x="matrix", y="character"))
and I would like to use the method *"["* for a *myClass* objects (but
changing the default *drop* argument from TRUE to FALSE):
setMethod("[","myClass",
function(x,i,j,...,drop=FALSE)
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
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
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
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",
2004 Sep 03
2
debugging an S4 method
Does anyone know how to use the equivalent of debug() on an S4 method? I would like R to enter the browser not for the generic function, but for the method of the class that I specify.
Thanks,
David
_____________________________
David Bickel http://davidbickel.com
Research Scientist
Pioneer Hi-Bred International
Bioinformatics & Exploratory Research
7250 NW 62nd Ave., PO Box 552
Johnston,
2006 Sep 22
1
setMethod
Hello R-help:
I was hoping someone could help me understand a particular function i came
across in a package:
"$.myClass" <- function( x, name ) {
sym = paste( "foo", name, sep = "_" )
if( is.loaded(sym) )
.Call(sym,x)
}
I understand the paste, and .Call part, but I'm not sure how this function
would get called? What exactly is
2010 Jun 13
1
S4 classes and S3 generic functions
A general goal for the next version of R is to make S4 and S3 play
better together.
As mentioned in a previous thread, one limitation has been that S3
generic functions, specifically the UseMethod() call, did not make use
of S4 inheritance when dispatching on general S4 objects.
This has been fixed in a version committed today (updated to rev 52267).
The code change is not large, but it
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