Displaying 20 results from an estimated 3000 matches similar to: "setMethod("min", "myclass", ...)"
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
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("[",
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
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 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]
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
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
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
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
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)
2000 Jun 26
2
nargs() inside "[.myclass"
I am writing a function to work with class I am defining. I have a question
about using nargs() inside of parentheses function. nargs() shows the same
for supplying 1 argument, or no arguments at all. Here is a small example:
> "[.myclass"<-function(x,...) print(nargs()-1)
> x<-c(1,2,3)
> class(x)<-"myclass"
> x[]
[1] 1
> x[1]
[1] 1
> x[1,2]
[1] 2
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 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
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
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"
2007 Mar 30
2
Replacing slot of S4 class in method of S4 class?
Dear all,
Assume that I have an S4 class "MyClass" with a slot "myname", which
is initialized to: myname="" in method("initialize"):
myclass <- new("MyClass", myname="")
Assume that class "MyClass" has a method "mymethod":
"mymethod.MyClass" <-
function(object, myname=character(0), ...) {
2005 Dec 07
1
Dots argument in apply method
Hello everyone,
I'm working on a package using S4 classes and methods and I ran into the
following "problem" when I tried to create an "apply" method for objects
of one of my new classes. I've found a way around the problem but I
wonder if I did not paint myself into the corner. I'd like your opinion
about that.
So I have an object "myObj" of class
2014 Jan 07
1
Why do methods of "initialize" have no "srcref" attribute as other S4 mehtods?
For documentation we use a system that generates Rd files from special
comments in the code. (inlinedocs).
It is crucial to be able to get the defining source code for objects like
methods to extract the comments from it.
Here is an R session that shows how this works for several kinds of methods
and (at the end of the session) how if fails for methods of "initialize"
>