Displaying 20 results from an estimated 2000 matches similar to: "How to reduce key strokes when defining S4 classes?"
2007 May 25
1
Question about setReplaceMethod
Hi
I have the code like I show below. The problem here is that I have a setReplacementMethod to set the value of my class slot. However, this function doesn't work when I call it within another function definition (declared by setMethod) of the same class. I do not understand this behavior that much. I'm wondering how to make this work? Any help would be really appreciated. Thank you.
2006 Sep 12
1
package.skeleton() in R-2.4.1
Hi
R version 2.4.0 alpha (2006-09-06 r39158)
MacOSX 10.4.7
There was a thread some time ago as to whether the structure created by
package.skeleton() would pass R CMD check.
I have an example where package.skeleton() gives an R file that gives an
error when sourced.
If I type
setClass("brob",
representation = representation
2011 Aug 03
1
NAMESPACE problems
Hi.
I am having difficulty following section 1.6.6 of the R-extensions manual.
I am trying to update the Brobdingnag package to include a NAMESPACE file (the
untb package requires the Brobdingnag package).
Without the NAMESPACE file, the package passes R CMD check cleanly.
However, if I include a NAMESPACE file, even an empty one, R CMD check
gives the following error in 00install.out:
2009 Mar 31
4
what is the preferred method to create a package local variable?
for the moment, I'm using:
.onAttach <- function(libname, pkgname) {
.bbg.db.conn <<- dbConnect(dbDriver("PostgreSQL"), user="blah","blah")
}
.onUnload <- function(libpath) {
dbDisconnect(.bbg.db.conn)
}
which results in a hidden global variable in the global environment.
I would prefer to make the assignment only in the package namespace.
2017 Jun 23
1
setReplaceMethod creates 'object' in the userworkspace
Hi,
I recognized that the function 'setReplaceMethod' is creating a
character vector in the user workspace having the name (e.g. "newClass")
of the class used as value. If you can sort out a mistake by myself, I
would like you to file a bug report.
BBFN,
Jonathan
setClass("newClass", representation(value="numeric"))
setMethod(f = "initialize",
2017 Jun 23
1
setReplaceMethod creates 'object' in the userworkspace
Hi,
I recognized that the function 'setReplaceMethod' is creating a
character vector in the user workspace having the name (e.g. "newClass")
of the class used as value. If you can sort out a mistake by myself, I
would like you to file a bug report.
BBFN,
Jonathan
setClass("newClass", representation(value="numeric"))
setMethod(f = "initialize",
2009 Oct 27
1
How to change a slot by a method?
In the following code, 'multiply' doesn't multiply a at x by 2. I'm
wondering how to define a method that can change the slot of a class.
$ Rscript setGeneric.R
> setClass(
+ Class='A',
+ representation=representation(
+ x='numeric'
+ )
+ )
[1] "A"
>
> setMethod(
+ f='initialize',
+
2011 Sep 14
1
S4 method dispatch
List,
In order to get rid of some old, unreadable S3 code in package sp, I'm
trying to rewrite things using S4 methods. Somewhere I fail, and I
cannot sort out why. In order to isolate the problem, I created two
functions, doNothing<- and dosth, and both should do nothing. The issue
is that in most cases they do nothing, but in some cases dosth(obj)
changes the class of obj and breaks with
2010 May 12
1
slot assignment in S4 classes
Hi R friends,
I'm still studying S4 classes and I have a question about slot assignment. Why would I have to use a special setter method [example 2 below] if I can assign data to a slot directly when I call new() [example 1 below]?
## first way to do it (the idiosyncratic way?)
setClass(Class = "TestClass", representation = representation(myDf = "data.frame"))
2008 Feb 24
2
Generic Functions
Hi
I have some problems in defining new generic functions and classes. Just
have a look at the following example:
require(fPortfolio)
setClass("PROBECLASS",
representation(
type="character"
)
)
isGeneric("setType<-")
#Returns
TRUE
#I would like to define a specific function for
2008 Feb 24
2
Generic Functions
Hi
I have some problems in defining new generic functions and classes. Just
have a look at the following example:
require(fPortfolio)
setClass("PROBECLASS",
representation(
type="character"
)
)
isGeneric("setType<-")
#Returns
TRUE
#I would like to define a specific function for
2007 Dec 23
1
Problem with initialize of S4 classes
Dear all
Below is the code for "scriptPreFilter.R" which gives the following result:
> source("scriptPreFilter.R")
> prefltr <- new("PreFilter", mad=c(0.5,0.01))
[1] "------initialize:PreFilter------"
[1] "------initialize:Filter------"
> str(prefltr)
Formal class 'PreFilter' [package ".GlobalEnv"] with 2 slots
2011 Dec 09
1
'callNextMethod' in a '[<-' function does not work ?
Hi the list,
I try to use callNextMethod in a setteur ([<-) but it does not work.
Any raison ?
Any other option ?
--- 8< ------------------
### Class B0 ###
setClass("B0" , representation(b0 = "numeric"))
setReplaceMethod("[","B0",function(x,i,j,value){x at b0 <- -value})
a <- new("B0")
a at b0 <- 3
a
a["b0"] <- 3
a
2005 Mar 26
2
Is there a diferent way to do this?
Hi,
I started creating a small class but I'm courious about how it is working.
To create a instance of my class "Partri" I write this at Rgui:
x <- new("Partri", name="Gilvan")
and to change the slot "name" of this instance, I write:
setName(x, newname="Justino")
It is not working, because when I type "x" at Rgui, it shows
2011 Aug 26
1
R.oo data members / inheritance
If someone is able, can you tell me if there is a better way to do this?
More specifically, do I have to rewrite all of the data members stuff and
extend stuff of parent class in the child class? See below. Thanks in
advance!
Example 1:
setConstructorS3("ClassA", function(A,x) {
if(missing(A))A=15;
if(missing(x))x=NA;
extend(Object(), "ClassA",
.size = A,
.x=x
2003 May 23
1
isSeekable returns F on seekable file
Hi,
Seems that on RWin 1.7.0 and 1.6.2 isSeekable returns F on binary files,
while seek() works as expected on the same connection - see example below:
> con = file(nm, "rb")
> isSeekable(con)
[1] FALSE
> readBin(con, double(), 10)
[1] 7.263824e-317 5.968155e-317 2.340685e-317 2.734062e-312
4.088386e-312 4.670335e-317
[7] 6.097545e-317 3.396341e-312 6.615484e-317
2008 Oct 23
1
Getting the panel location of a xyplot matrix using a mouse click in a GDCanvas
Hi:
I would like to find out the panel of a xyplot matrix where a mouse clicked.
I know this functionality is already bundled in trellis.focus but I can't
use it because I am coding a stand alone application in Java using with
GDCanvas as a graphics device.
I tried calling trellis.focus from Java with:
re.eval("t = trellis.focus()"));
However it did not work for an embedded
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
2009 Dec 30
1
Fwd: Negbin Error Warnings
Dear Clara,
Thanks for the reply. I am forwarding your message to the list, ok.
When I wrote was a way of get further information to help the helpers.
happy holidays,
milton
---------- Forwarded message ----------
From: Clara Brück <clara_brueck@web.de>
Date: 2009/12/30
Subject: Re: [R] Negbin Error Warnings
To: milton ruser <milton.ruser@gmail.com>
Dear Milton,
Thanks for
2004 Mar 16
2
Documentation on how to put classes and methods in packages with namespace?
Documentation on how to put classes and methods in packages with namespace?
How should I define my classes and methods in "dynamicGraph"???
(That is - Can some one point me to the documentation on
how to put classes and methods in packages with a namespace? )
Currently it is done by the code below.
This gives problems, when a workspace with a "dynmaicGraph" is