R: Using italics and a variable in the header

Using R 2.14.0 with Windows 7, I want to include italics and a variable in my title using R plot (). Here is the code:

ps=c(1,2,3)

layout(matrix(1:3,1,3))

#this works but isn't what I want
for(i in 1:3){
    plot(1,1,main=expression(paste(italic(p),'=5')))
}
#this doesn't work
for(i in 1:3){
    plot(1,1,main=expression(paste(italic(p),'=',ps[i])))
}
#this doesn't work either
for(i in 1:3){
    plot(1,1,main=paste(expression(paste(italic(p),'=')),ps[i]))
}

What I want in the header is p [italics] = ps value during this iteration. For example, for the first iteration, "p = 0.1"

Any help would be greatly appreciated. Thank.

+5
source share
1 answer

Does it help?

ps=c(1,2,3)
layout(matrix(1:3,1,3))
for(i in 1:3){
    plot(1,1,main=substitute(paste(italic(p), " = 0.", x, sep=""), list(x=ps[i])))
}

Also look at this this question.

+5
source

All Articles