Sorry for the very stupid question, I have been googleing for a while without finding a solution. I need to create several plots iteratively, whose titles are (1) picked from a previously created vector and (2) must be italicized. I have tried several options with no adequate results, stuff like this:
# Main titles
m <- paste(LETTERS[1:10], LETTERS[11:20])
# Plots
for(i in 1:10){
x <- runif(10, 1, 20)
y <- runif(10, 1, 20)
X11()
plot(x,y, main = expression(italic(m[i])))
}
But what I got are plots with an "m" with an "i" as a subscript, not the corresponding content in the vector. Any idea?
Here is the way to achieve what you want
# Main titles
m <- paste(LETTERS[1:10], LETTERS[11:20])
# Plots
for(i in 1:10){
x <- runif(10, 1, 20)
y <- runif(10, 1, 20)
X11()
plot(x,y, main = substitute(paste(italic(x)), list(x = m[i])))
}