[R] bquote in list to be used with do.plot()
David Winsemius
dwinsemius at comcast.net
Sun Oct 9 05:13:45 CEST 2016
> On Oct 8, 2016, at 9:50 AM, Marc Girondot via R-help <r-help at r-project.org> wrote:
>
> Dear members,
>
> Has someone have a solution to include a bquote() statement in a list to be used with do.call() ?
>
> Here is an exemple:
> scaleY <- 10000
> plot(x=1, y=1, ylab=bquote(.(format(scaleY), scientific=FALSE)^"-1"))
>
> Like that, it works.
>
> Now he same in a list:
> L <- list(x=1, y=1, ylab=bquote(.(format(scaleY), scientific=FALSE)^"-1"))
> do.call(plot, L)
> Error in "10000"^"-1" : argument non numérique pour un opérateur binaire
>
> It produces an error.
>
> Any solution?
>
> (I tries also with substitute() and expression() but I fail also)
Try this:
L <- list(x=1, y=1, ylab=as.expression(bquote(.(format(scaleY), scientific=FALSE)^"-1")))
do.call(plot, L)
`bquote` actually doesn't return an object with mode expression but rather of mode call, so sometimes as.expression is needed to coerce the result. The `expression` function isn't really designed to do that.
>
> Thanks
>
> Marc
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.
David Winsemius
Alameda, CA, USA
More information about the R-help
mailing list