Skip to content

"formula plotting" -> substitute pecularity

2 messages · Martin Maechler, Peter Dalgaard

#
This is something between a question and a bug report.
     {sometimes one should first ask on R-help before sending to R-bugs....}

I wanted to plot (.) a formula with "..."

 ## Works :
 e0 <- expression(T(x[1],...x[n])*",  "*N[1] == 101) # works ok
 plot(1, main = e0)

## Now, need substitute, to replace with value of variableThis works

 nn <- 102
 (e1 <- substitute(T(x[1],...x[n])*",  "*N[1] == n1, list(n1=nn)))
 plot(1,main=e1)
 ## this works, but only because of a typo: I forgot one ","

## This ``should'' work, but does not :

 e2 <- substitute(T(x[1],...,x[n])*",  "*N[1] == n1, list(n1=nn))

 ##>>  Error: ... used in an incorrect context

--
Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO D10	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
#
Martin Maechler <maechler at stat.math.ethz.ch> writes:
..
I think that is a bug. Simplest variant:
Error: ... used in an incorrect context

I think the basic issue is that when you use ... in a function,
substitute will try to match it against the actual parameter list,
e.g.
a(2)
a(2, 3, 4)

However, when there's no ... argument to f, substitute will complain,
as would any other function trying to handle ... but the semantics of
substitute should be different.

Robert?