Displaying 20 results from an estimated 20000 matches similar to: "packaging a package addon"
2003 Aug 26
2
Seeking Packaging advice
I have two questions about packaging up code.
1) Weave/tangle advisable?
In the course of extending some C code already in S, I had to work out
the underlying math. It seems to me useful to keep this information
with the code, using Knuth's tangle/weave type tools. I know there is
some support for this in R code, but my question is about the wisdow of
doing this with C (or Fortran, 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
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 02
1
Too generic with S4 methods?
I tried the following (relevant excerpt only)
setMethod("likelihood",
signature(spec="Specification", covs="vector",
states="vector"),
function(spec, covs, states) {
####
setMethod("likelihood",
signature(model="Model", path="matrix"),
function(model, path) {
This
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
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 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 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
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 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 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 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
2011 Jul 19
1
"may be used in an incorrect context"
R CMD check tells me
* checking R code for possible problems ... NOTE
agexact.fit.rds: ... may be used in an incorrect context: ?optim(init,
agfitfn, ...)?
Warning: <anonymous>: ... may be used in an incorrect context: ?optim(init, agfitfn, ...)?
Can anyone tell me what this message means? My searches haven't turned
up anything useful. This is with R 2.7 and 2.9.
The message
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)
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
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
2003 Sep 11
2
(structured) programming style
I find that because R functions are call by value, and because there are
no pointer or reference types (a la C++), I am making fairly heavy use
of lexical scoping to modify variables. E.g.
outer <- function() {
m <- matrix(0, 2, 2)
inner <- function() {
m[2,2] <<- 3
...
}
}
I am not too pleased with this, as it violates basic rules of structured
programming, namely
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.
2003 Aug 15
2
Error in model.frame
I am getting an error that I don't understand, and wonder if anyone
could explain what's going on. I call a function defined thus:
clogit.rds<-function(formula,data,extra.data,response.prob,
na.action=getOption("na.action"),subset=NULL,
control=coxph.control()){
method="exact" # only option for now
mf<-match.call()