Im trying to print $\lambda = $ lambda"
(where lambda outside of the dollar signs is a variable) on the xlabel of a plot I'm making in R using the latex2exp
package. When I use:
xlab = paste(TeX(r'($\\lambda = $)'), lambda)
as is instructed for R version 4.0 and above (which I am using) it gives me:
", "", lambda, , , , phantom() == phantom(
on the xlabel in the pdf I created of the plot. When I use:
xlab = paste("$\\lambda = $", lambda)
It literally prints the characters:
$\lambda = $ lambda
Im not sure what the significance of only one \
showing up instead of two backslashes is. I tried asking about this problem in a different way in this thread: TeX("$\lambda$") doesn't work in R , but I couldnt figure it out. I dont want to use the sweave file method with the kntir and tikzDevice packages, I kind of want to figure out why latex2exp
isnt working. Please help
xlab = TeX(paste0("$\\lambda = ", lambda, "$"))
.latex2exp
works properly, so you concluded that there is a problem with your code for generating multiple plots. To find out what the problem is you therefore need to show the code that actually reproduces the problem. Show a full R script that, when executed from start to finish in R 4.x, results in the output you describe. Try to make it minimal, i.e., remove statements or details that are not needed to reproduce the problem.