[R] Bug in function arguments autocomplete and ellipsis?

Roman Olson rom@no|@on @end|ng |rom yon@e|@@c@kr
Thu May 7 09:46:05 CEST 2020


Dear All,

I am wondering whether function arguments autocomplete causes a bug when additional ellipsis arguments are used.

Example:
a = function(robot) {
    cat(robot, "\n")
 }
a(r=5) prints 5, meaning that r is autocompleted to “robot”. Not sure if this is normal behavior, but this does not cause problems.

This would be fine, but somehow causes problems when there is an additional ellipsis argument that can be used to autocomplete an already existing argument. In the example below, when we are calling sens.analysis.all, everything starting with q is an additional argument (…). Now, k is missed completely. And that is because there is another actual argument that starts with k — key.legend.axes (it is assigned to 4 instead). If “k=4” is changed to “kk=4” the problem disappears.  

sens.analysis.all <- function(func, outgrid, parvec, parmin, parmax,
                              length.pgrid, outvname, zlim, plabs,
                              gridlab, mylog, outlog=FALSE, ytick=NULL,
                              xline=NULL, yline=NULL, mypal=topo.colors,
                              key.legend.axes=NULL, plot.guidance=FALSE, ... ) {

   cat(..1, "\n")
   cat(..2, "\n")
   cat(..3, "\n")
 
   out=1
   out
} 

out = sens.analysis.all(numer.wait.times.wrps, NA,
     c(5.4, 0.008, 1.5), c(4.9, 0.0079, 2.0), c(5.5, 0.0090, 3.5),
       length.pgrid=10, outvname="cvs", zlim=c(0.3, 2),
       plabs=c("mu", "lambda", "b"), gridlab="Soil Moisture [mm]",
       mylog=FALSE, outlog=FALSE, yline=2, plot.guidance=FALSE, q=3.1, k=4, y.c=670,
       realgrid=seq(630, 670, by=4), myseed=0,
       nt=1000000, burnin=300000, bin.cutoff=500,
       bdW.prelim=prec.struct.Mal)


More information about the R-help mailing list