On Fri, 27 Mar 2020, peter dalgaard wrote:
It's not new anyway. You see the same behaviour with
boxplot(dat, ylab=quote(X[2]))
and it boils down to the use of do.call("bxp", ...) in the internals.
As a general matter, expression() exists to prevent this sort of confusion,
e.g., in this construction,
X <- quote(Y+1); bquote(f(.(X)))
f(Y + 1)
is indistinguishable from just entering f(Y+1), so f has no way of detecting whether or
not it is intended to evaluate Y + 1. The same thing is happening with do.call: call
objects are being "spliced into" the generated call, and if they are not
protected with expression, you have the trouble.
do.call has a 'quote' argument that can be used to address this. The
default is quote = FALSE, which means all arguments will be evaluated
by the called function. Which is fine for arguments that evaluate to
themselves. For symbols and calls it isn't.
I did try to make the case some time ago that quote = TRUE should be
the default but I lost that argument.
It might be worth revisiting that, or at least reviewing the uses of
do.call in our code sometime (there are a couple of hundred).
Best,
luke
I don't know whether it is worth trying to change this. You know the workaround.
-pd
On 27 Mar 2020, at 02:55 , Marius Hofert <marius.hof...@uwaterloo.ca> wrote:
Hi,
Is this expected behavior (R-3.6.0)?
dat <- cbind(x = 1:10, y = 10:1)
ylab <- substitute(X[t], list(t = 2))
plot(dat, ylab = ylab) # works (correctly displays ylab)
boxplot(dat, ylab = ylab) # fails
boxplot(dat, ylab = as.expression(ylab)) # works
Thanks & cheers,
M
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
--
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa Phone: 319-335-3386
Department of Statistics and Fax: 319-335-3017
Actuarial Science
241 Schaeffer Hall email: luke-tier...@uiowa.edu
Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel