I am trying to add labels into a factor with Latex expressions with latex2exp
with the following reproducible code:
library(latex2exp)
datplot <- setNames(data.frame(matrix(ncol = 4,nrow = 216000)), c('Fz','Cz','Pz','bta'))
datplot$bta <- rep(c('b0','b1','b1-b0'), each=72000)
datplot$bta <- factor(datplot$bta, labels=c("b0" = TeX("$\beta_0\cdot x\; (x=0)$"),
"b1" = TeX("$\beta_0+\beta_1\cdot x\; (x=1)$"),
"b1-b0" = TeX("$\beta_0+\beta_1\cdot x-\beta_0= \beta_1\cdot x\; (x=1)$")))
Unfortunately, I keep having the following error and I don't know the source of it:
Error: '\c' is an unrecognized escape in character string starting ""$\beta_0\c"
However, I've tried the plotmath expressions with this interpreter and they are all correct.