[R] Use of ellipses ... in argument list of optim(), integrate(), etc.

From: Ravi Varadhan <rvaradhan_at_jhmi.edu>
Date: Thu, 13 Mar 2008 12:05:43 -0400


I have noticed that there is a change in the use of ellipses or . in R versions 2.6.1 and later. In versions 2.5.1 and earlier, the . were always at the end of the argument list, but in 2.6.1 they are placed after the main arguments and before method control arguments. This results in the user having to specify the exact (complete) names of the control arguments, i.e. partial matching is not allowed.  

An example with integrate() :  

> integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdiv=1000)

Error in f(x, ...) : unused argument(s) (subdiv = 1000)  

> integrate(function(x) exp(-x^2), lower=-Inf, upper=L, subdivisions=1000)

1.633051 with absolute error < 1.6e-06    

Here is an example with optim():  

> res <- optim(50, fw, meth="BFGS", control=list(maxit=20000, temp=20,

Error in fn(par, ...) : unused argument(s) (meth = "BFGS")    

FYI, I am using R version 2.6.1 on Windows XP.  

May I ask what the rationale behind this change is and also about the pros and cons of the two different ways of specifying (.)?  

Thank you very much.  



Ravi Varadhan, Ph.D.

Assistant Professor, The Center on Aging and Health

Division of Geriatric Medicine and Gerontology

Johns Hopkins University

Ph: (410) 502-2619

Fax: (410) 614-9625

Email: rvaradhan_at_jhmi.edu

Webpage: http://www.jhsph.edu/agingandhealth/People/Faculty/Varadhan.html  


        [[alternative HTML version deleted]]

R-help_at_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. Received on Thu 13 Mar 2008 - 16:07:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 13 Mar 2008 - 18:30:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive