No subject

Christian Hoffmann christian.hoffmann at
Wed Feb 14 14:30:07 CET 2001

Thanks for the tip to p.dalgaard and Prof Brian Ripley:

For reasons that I have forgotten, the value of an assignment function
is always passed using an argument called "value", so try changing
"sub" to "value".

The last argument of any assignment function has to be named `value'.
This is different from S, and is in the FAQ, section 3.3.3:

"In R, the last argument (which corresponds to the right hand side) of an
      assignment function must be named value. E.g., fun(a) <- b is
evaluated as
      (fun<-)(a, value = b)." 

The original question was

> I am trying to create the assignment function:
> "substring<-" <- function(text, first, last=100000, sub) {
> Error in substr<-(*tmp*, 3, 4, value = "IS") : 
> 	unused argument(s) (value ...)


Is there a reference to the obseravation, that in R, missing parameters of
a function can be "declared" using NULL, as in

xxx <- function (x, miss=NULL) {
  otherfunction <- function (x, missOther=NULL) { .. }
  otherfunction(x, miss)

The solution of R is preferable to S+3.4's, since it allows functions
within functions to have missing parameters without the (ugly) construct:

xxx <- function (x, miss) {
  otherfunction <- function (x, miss) { .. }
if (missing(miss)) otherfunction(x)
else otherfunction(x, miss)

Thanks again for your help
-christian W. Hoffmann
Mathematics and Statistical Computing
Landscape Modeling and Web Applications
Swiss Federal Research Institute WSL 
Zuercherstrasse 111
CH-8903 Birmensdorf, Switzerland
phone: ++41-1-739 22 77    fax: ++41-1-739 22 15
e-mail: Hoffmann at WSL.CH

r-help mailing list -- Read
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at

More information about the R-help mailing list