[Rd] depends/suggests when making a new generic to override a function in a user package

2012-07-06 Thread Dr Gregory Jefferis
Dear R developers,

I would like to add a new S3 generic to override a function in a user package, 
specifically:

STAR::as.repeatedTrain

I have followed the recommendation here:

http://cran.r-project.org/doc/manuals/R-exts.html#Adding-new-generics

doing this:

as.repeatedTrain<-function(x,...){
 UseMethod("as.repeatedTrain")
}

as.repeatedTrain.default<-function(x,...) {
 STAR::as.repeatedTrain(x)
}

but the question now arises, how do I make sure that my as.repeatedTrain 
generic function is used in preference to STAR's. If my package suggests STAR, 
then STAR will likely be loaded afterwards and my generic will get clobbered. 
So at the moment I have made my package depend on STAR rather than suggest it. 
However I will only occasionally use STAR, and it is quite a big package with a 
number of dependencies and I would prefer to avoid this. Is there another 
approach? I assume this isn't a problem for a non-generic in a base package 
because they are loaded first.

Many thanks for any suggestions,

Greg Jefferis.
--
Gregory Jefferis, PhD  
Division of Neurobiology   
MRC Laboratory of Molecular Biology,   
Hills Road,
Cambridge, CB2 0QH, UK.

http://www2.mrc-lmb.cam.ac.uk/group-leaders/h-to-m/g-jefferis
http://www.neuroscience.cam.ac.uk/directory/profile.php?gsxej2
http://flybrain.stanford.edu

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] creating a '[' method for an S4 class

2012-07-06 Thread Benilton Carvalho
Hi,

I'm working on an S4 class that is expected to behave like an array.

I have some difficulties when defining '[' and I wonder if someone
could point me to the right direction:

1) Call the S4 object "obj"
2) Assume dim(obj) = c(10, 4, 2)
3) Suppose someone calls: obj[1:3,] , which is a mistake, given
dim(obj); how do I detect such situations?

Thank you very much for your attention and time,
benilton

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel