I just found out that sometimes .() is needed to create dynamically-labeled plots in base R:
png("~/Desktop/dterror.png")
par(mfrow = c(1, 2))
DT[ , {
plot(1:10)
text(2, 9, bquote(R^2 == .(summary(lm(y ~ x))$r.squared)))}]
plot(1:10)
text(2, 9, bquote(R^2 == .(summary(lm(y ~ x, data = DT))$r.squared)))
dev.off()

When used outside of [.data.table, the text is converted (as expected) to the evaluated value of the regression. But [.data.table (I imagine) is detecting this as an alias for list and substituting, leading to the unexpected result on the left.
Workaround for now is to use with(DT, {...}) instead of calling [.data.table but obviously this won't work in situations requiring other arguments of [.data.table.
I just found out that sometimes
.()is needed to create dynamically-labeled plots inbaseR:When used outside of
[.data.table, the text is converted (as expected) to the evaluated value of the regression. But[.data.table(I imagine) is detecting this as an alias forlistand substituting, leading to the unexpected result on the left.Workaround for now is to use
with(DT, {...})instead of calling[.data.tablebut obviously this won't work in situations requiring other arguments of[.data.table.