[R] Plot math symbol with string and number

John Smith j@whct @end|ng |rom gm@||@com
Sun Aug 16 23:53:23 CEST 2020


Dear Helpers,

I would like to make plots with titles for different data sets and
different parameters. So a useful title should combine data name
and parameter for clarity. The following is a simplified code example with
two plots. The first title doesn't show sigma as a math symbol, while the
second one doesn't contain the s value as a numeric value - I could
manually change the s value, but when there are many different s values,
this is not a good solution. Thanks!

s <- 1
y <- rnorm(100)
plot(y, main=paste("data", "sigma=", s))
plot(y, main=expression(paste("data", sigma,"=", s)))

	[[alternative HTML version deleted]]



More information about the R-help mailing list