1
a <- "A"
bquote(.(as.name(a)) = 4)

Error: unexpected '=' in "bquote(.(as.name(a)) ="

bquote(A = 4)

Error in bquote(A = 4) : unused argument (A = 4)

a <- "A"
bquote(f(.(as.name(a)) = 4))

Error: unexpected '=' in "bquote(f(.(as.name(a)) ="

How can I get around this?

  • I'm AFK but try `bquote(expr = .(as.name(a)) = 4)` I think it should work. Else try `bquote('=' (.(as.name(a)), 4))`. – moodymudskipper Oct 17 '20 at 23:35
  • Is this to create an expression for `plotmath`? Then you want a double equals `==`, not a single one. Or are you trying to create an assignment expression? Here's another case where using `<-` would work better than `=` – MrFlick Oct 18 '20 at 00:10

1 Answers1

2

We don't need as.name

plot(1, 1, main = bquote(.(a) == 4))

-output

enter image description here


or another option with quotes

plot(1, 1, main = bquote(.(a)~'= 4'))
akrun
  • 874,273
  • 37
  • 540
  • 662