Displaying 20 results from an estimated 10000 matches similar to: "Too generic with S4 methods?"
2005 Aug 18
2
Use of contains in S4 classes
setClass("B", representation=representation("B", extra="numeric))
setClass("B", representation=representation(extra="numeric"),
contains="B")
Are these the same? If not, how do they differ?
What about
setClass("B", representation=representation("B", extra="numeric"),
contains="B")
?
As far as I can
2004 Feb 07
2
R does in memory analysis only?
I wonder if someone would confirm something I'm 99% sure of from the
docs and discussion on the list, but can't find stated explicitly:
R works only on problems that fit into (real or virtual) memory.
Thus, even if you have a problem (e.g., simple regression) that could be
solved by doing some operation on each row of a dataset at a time, you
can't solve it unless the entire dataset
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
2003 Oct 30
4
packaging a package addon
I am trying to package some code that is a tweak to the survival
package. When I asked earlier, the list consensus was that it would be
best to do this as a separate package, dependent on survival.
This is proving a bit tricky.
I have some run-time and compile time concerns.
Run-time, my R code needs R code from survival, and my C code needs C
functions from survival. Will this all be
2005 May 23
2
Documentation of S3 and S4 classes, inheritance
I'd like to have a class A that computes a likelihood, and a subclass B
that computes the same likelihood by sometimes throws in an additional
term (B includes measurement error).
So B's likelihood needs to call A's, and then (sometimes) multiply by an
additional term.
It sounds as if, in the S3 scheme, NextMethod is supposed to do this:
like.A <- function(stuff) compute value
2004 Nov 05
0
R check passes code and docs that don't match
I have code and documentation that don't match, but R CMD check didn't
flag it.
in mspath.R
mspath <- function(formula, # formula with observed Markov states
~ observation times (required)
qmatrix, # matrix of 1s and 0s with indices of
allowed transitions (diagonal is ignored) (required)
misc = FALSE,
ematrix = NULL, # matrix
2004 Aug 20
2
Error messages and C
I am calling a C (C++ really) function via the .C interface.
Sometimes when things go wrong I want to return an error message.
1. R provides C functions error and warning which look about right.
But exactly how does this exit, and in particular what happens with
cleaning up, calling C++ destructors, and unwinding the stack? Will I
get memory leaks?
2. Before I discovered those functions, I
2003 May 06
1
Seeking packaging advice
I have 3 questions about creating a package for R, and would appreciate
any guidance.
1. Demonstrating the packaged code requires some support code files. It
would seem natural to put these in the demo directory, but "Writing R
extensions" says files in demo should be suitable for runing from
demo(). The support files are not intended to be run from the top
level. How should I handle
2003 Nov 05
1
Contributing to the R Extensions documentation
I thought there were some gaps in the R Extensions document; in
particular, I was left wondering how to create a list. I think a
paragraph on it would be useful.
I would be happy to contribute the paragraph, but I'm not sure if
there's interest or what the procedure is. Can anyone advise me?
Though I was looking at the 1.7.0 version, I just checked 1.8.0 and the
relevant section seems
2005 Aug 18
1
problem with repeated formal arguments and ...
I want to add an argument if it is not present. Following the Green
Book, p. 337:
test <- function(x, ...){
dots <- list(...)
if (!hasArg(from))
from <- 0
else
from <- dots$from
curve(x, from=from, ...)
}
> test(sin)
> test(sin, from=4)
Error in curve(x, from = from, ...) : formal argument "from" matched by
multiple actual arguments
The FAQ says, in
2003 Oct 02
2
Plot can't forget bad parameters
When I give plot some bad paramaters, it keeps giving me error messages
forever after. I think the last time this happened, I even got the
error messages for completely unrelated, non-graphical functions.
Here's a recent example:
> plot(it[[31]][,c(1, 3)], type="b", usr=c(0, 20, -20, 5))
Warning messages:
1: parameter "usr" couldn't be set in high-level plot()
2004 Mar 24
1
snow documentation comments
There are a few points I found unclear or unmentioned in the snow
documentation (mostly I looked at the cluster.html web page). I thought
I'd mention them here.
What is the start up environment for the children?
--------------------------------------------------
My best guess at the answer is in parentheses
Do they inherit shell variables? (no)
Do they inherit variables set in R or other
2003 Jul 17
3
Looking to maximize a conditional likelihood
I want to maximize a conditional likelihood function that is basically
logistic conditional on the number of successes within strata. What
would be a good starting place for this? A complication is that the
denominator includes a term that is the sum over all permutations.
Although there is no time dimension to the problem, it's possible a
degenerate use of the Cox proportional hazards
2004 Dec 09
1
Calling R a la carte?
I have written an R package, mostly implemented in C++. It works.
I want to do unit tests of the C++ code, as well as higher level tests
from R. I use the boost test framework for this, part of which is a
library which wants to be the thing that starts everything running
(i.e., main).
My code has a few invocations of R functions--just error at the moment,
I think. The list might grow. So I
2005 May 23
1
SV: Documentation of S3 and S4 classes, inheritance
I am sure that I do not have the answer to your question - but I would like to add to your views regarding the S4-issue. I've been involved in the gRbase package for graphical modelling in R. The first version was implemented in S4 but now we have made a roll-back to using S3 methods.
While, I can see that S3 is not really comprehensive enough for 'proper' object oriented
2004 Aug 20
1
R CMD check testing environment
I can't tell from the docs ("Writing R Extensions" 1.9.1) exactly what
environment the tests, examples, and vignettes that R CMD check tries to
run are in.
In particular:
1) how do I get the package loaded?
2) how do I access data in the data/ directory?
3) where is the material in the other directories? (e.g., has inst/
material been installed? where?)
Apparently (section 1.3)
2006 Jan 31
2
an unpleasant interaction of environments and generic functions
I've run into an unpleasant oddity involving the interaction of
environments and generic functions. I want to check my diagnosis, and
see if there is a good way to avoid the problem.
Problem:
A library defines
"foo" <- function(object) 1
setMethod("foo", c("matrix"), function(object) 30)
After loading the library
foo(0) is 1
foo(matrix()) is 30
foo is a
2003 Jun 03
2
Question about looking up names
I think I now understand how R looks up names. Could anyone tell me if
I have this right?
First it looks up the nested environments created by lexical scoping.
Then, if it gets to the top (.GlobalEnv) it also looks through the list
of things that have been "attach"ed.
It never looks in the call stack unless you explicitly ask it to, or
mess with the environment frames.
The reason I
2009 Oct 23
2
mysteriously persistent generic definition
Originally I made a function yearStop that took an argument "object". I
made a generic, but later changed the argument to "x". R keeps
resurrecting the old definition. Could anyone explain what is going on,
or how to fix it? Note particularly the end of the transcript below: I
remove the generic, verify that the symbol is undefined, make a new
function, and then make a
2003 Nov 04
1
Architecting an optimization with external calls
I have a likelihood I would like to compute using C++ and then
optimize. It has data that need to persist across individual calls to
the likelihood. I'd appreciate any recommendations about the best way
to do this. There are several, related issues.
1. Use the R optimizer or a C optimizer?
Because of the persistence problems (see below), using a C optimizer has
a certain attraction.