Displaying 20 results from an estimated 800 matches similar to: "Question about setReplaceMethod"
2009 Oct 27
1
How to reduce key strokes when defining S4 classes?
I feel tedious when I define a S4 class and the methods. For each
method, I have to call both setMethod and setGeneric (or both
setReplaceMethod and setGeneric). I would like a more compact grammar
so that I can reduce the key strokes. I'm wondering if there is a
better way available.
setClass(
Class='A',
representation=representation(
x='numeric'
)
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",
2006 Oct 31
1
setReplaceMethod
Hi
If x <- 1:10 then x[5] <- 1i will promote
x to be a complex vector.
Suppose I have an S4 class "brob", and have functions
is.brob(), as.brob(), as.numeric() and so forth (minimal self-contained
code below).
If x is numeric (1:10, say) and y is a brob, what
is the best way to make
x[5] <- y
promote x to a brob in the same way as the complex example?
Or is
2017 Jun 27
0
[Rd] setReplaceMethod creates 'object' in the userworkspace
>>>>> Jonathan Fritzemeier <clausjonathan.fritzemeier at uni-duesseldorf.de>
>>>>> on Fri, 23 Jun 2017 16:15:30 +0200 writes:
> 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
2005 Jun 04
3
How to change the value of a class slot
I defined an S4 class with a slot i. Then I wrote a regular function
that attempted to increment i.
This didn't work, apparently because of the general rule that a function
can't change the values of its arguments outside the function. I gather
there are ways around it, but the Green book admonishes "cheating on the
S evaluation model is to be avoided" (p. 190).
Thinking that
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
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
2003 Jul 26
2
How to make "<-" generic?
Hi,
perhaps a little bit unusual: is it possible to use "<- " as generic function
with a new signature?
The following example doesn't work:
> isGeneric("<-")
[1] FALSE
> setClass("A",representation(x = "numeric"))
[1] "A"
> setClass("B",representation(x = "numeric"))
[1] "B"
> myAssign.A <-
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
2011 Apr 26
2
Wish R Core had a standard format (or generic function) for "newdata" objects
Is anybody working on a way to standardize the creation of "newdata"
objects for predict methods?
When using predict, I find it difficult/tedious to create newdata data
frames when there are many variables. It is necessary to set all
variables at the mean/mode/median, and then for some variables of
interest, one has to insert values for which predictions are desired.
I was at a
2009 Dec 30
2
Negbin Error Warnings
Hi,
I ran a negative binomial regression (NBR) using the Zelig-package and the negbin model.
When I then try to use the simumlation approach using the setx () and sim() functions to calculate expected values
and first difference for different levels of one of my independent variables, I get 50 errors warnings, telling me that the calculation rpois produced NAs. However, the data I use
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"))
2011 Dec 16
1
Zellig Error Message
I'm trying to calculate predicted probabilities in R with Zelig and keep
getting the following error.
Can anyone help?
> x.low <- setx(mod, type=1)Error in dta[complete.cases(mf), names(dta) %in% vars, drop = FALSE] :
incorrect number of dimensions
When I ran the model, I ran everything but the explanatory variable as a
numeric variable. Now, I'm trying everything and no
2009 Feb 19
0
Zelig method setx()
Hello,
I am attempting to "automate" a Bayesian normal linear regression
using Zelig. Basically, I have a list containing several zelig()
objects, each having a different formula, same data set, and same
model (normal.bayes).
My problem lies in the setx() method, where I am setting a numeric
parameter to a value other than the mean. This is straightforward if
I input the parameters
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
2008 Apr 02
1
"[<-" plus drop-type extra argument
Hello
I am writing a replacement method for an S4 class and want to pass
an additional argument to "[<-"() along the lines of "["()'s "drop"
argument.
Specifically, I have an S4 class, call it "foo", with a slot 'x'
that is a
vector and a slot 'NC' that is a scalar.
I want to be able to pass a Boolean argument to the
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), ...) {
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