Skip to content

bquoted annotations are evaluated #624

@bastistician

Description

@bastistician
plot(0, 0, main = bquote(pi == .(pi)))

library(tinyplot)
 plt(0, 0, main = bquote(pi == .(pi)))  # "TRUE"
 plt(0, 0, main = bquote(foo == .(pi)))
## Error in draw_title(main, sub, cap, xlab, ylab, legend, legend_args, opar,  : 
##   object 'foo' not found

A workaround is to explicitly convert the call to an expression:

plt(0, 0, main = as.expression(bquote(foo == .(pi))))

Relevant ?plotmath fragment:

In most cases other language objects (names and calls, including
formulas) are coerced to expressions and so can also be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions