[R] S4 generic and method arguments -- expanded signature

2010-04-25 Thread EJ Nikelski
Hello R-List,

** This e-mail was initially bounced. Please forgive any duplicates.**

   I'm creating a new generic function and 3 associated methods, in
which each of the methods only needs a subset of the arguments
specified in the generic.

So, I create the generic like so (with the signature defaulting to all
of the args) ...

setGeneric(
   name=myFunction,
   def = function(filename,
   dimLengths,
   dimSteps,
   dimStarts,
   likeTemplate,
   likeFile) {
standardGeneric(myFunction) }
)

In my first method, for example, I only need access to the first 4
args, so I try ...

setMethod(
   myFunction,
   signature=signature(filename=character,
   dimLengths=numeric,
   dimSteps=numeric,
   dimStarts=numeric),
   definition=function(filename=filename,
   dimLengths=NULL,
dimSteps=NULL, dimStarts=NULL) { ... }

Now, when I build the package, I get the following warning ...

In method for function myFunction: expanding the
signature to include omitted arguments in definition: likeTemplate =
missing, likeFile = missing

I've read in S4 Classes in 15 pages, more or less (John Chambers),
that a method *can* contain a subset of the args in the generic, so
I'm uncertain why R is expanding the signature.  I suspect that all
methods need to include all signature elements specified within the
generic, even if the signature elements are not in the method's arg
list ... is this correct?

At any rate, I do not want the signature to be expanded, since (1) I
don't want to add these 2 missing args to my Rd \alias's, and (2) I
don't want to have to add
these 2 missing args to the \S4method Rd entry, as it makes these
entries horribly long and does not really add any useful information
for the user.

 Perhaps I'm not setting up these methods optimally?  What I *want*
is to be able to have 3 methods that could be invoked as follows:

Method 1: myFunction(filename, dimLengths, dimSteps, dimStarts)
Method 2: myFunction(filename, likeTemplate=templete)   -
likeTemplate=character
Method 3: myFunction(filename, likeFile=file)   - likeFile=character

Note that the arguments for Methods 2  3 are both (character, character).
Does anyone have any suggestions that would both solve my S4 dispatch
problem, whilst keeping the Rd doc user friendly (i.e., not polluting
the entries with missing arguments)?

Thanks in advance for any suggestions.

Sincerely,

-Jim

 sessionInfo()
R version 2.10.1 (2009-12-14)
i386-apple-darwin9.8.0

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/C/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base


-- 
=
Jim Nikelski, Ph.D.
Postdoctoral Research Fellow
Bloomfield Centre for Research in Aging
Lady Davis Institute for Medical Research
Sir Mortimer B. Davis - Jewish General Hospital
McGill University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Passing filenames to the getopt package

2009-11-19 Thread EJ Nikelski
Hi all,

I've finally started to use Rscript for my statistical scripting
needs, and find I'm being blocked by what must be a very simple
problem.  Specifically, the command lines for my scripts usually
contain: (1) the script name, (2) one or more options and their
arguments, and finally, (3) one or more filenames to be processed.
While the getopt package seems to provide me with excellent option
reading functionality, it however, also wants to read the trailing
filenames as options as well -- and then fails.  Am I missing
something obvious?

Thanks,

-Jim

 version
  _
platform   i386-apple-darwin8.11.1
arch   i386
os darwin8.11.1
system i386, darwin8.11.1
status
major  2
minor  9.2
year   2009
month  08
day24
svn rev49384
language   R
version.string R version 2.9.2 (2009-08-24)


-- 
=
Jim Nikelski, Ph.D.
Postdoctoral Research Fellow
Bloomfield Centre for Research in Aging
Lady Davis Institute for Medical Research
Sir Mortimer B. Davis - Jewish General Hospital
McGill University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.