There argument you are passing to main
needs a couple of changes.
To use R's plotmath specials (i.e. things like
italic()
), it should be an expression object rather than a character string. That means doing something like this:main = expression(paste("Length-Freq of", italic("E. coruscans"), "by Gear"))
instead of this:
main = paste("Length-Freq of", italic("E. coruscans"), "by Gear")
In addition, you are wanting to italicize
i
's value rather than its name, but if you just typeitalic(i)
, lattice will renderi
's name as a little italic "i" for each species. Usebquote()
orsubstitute()
to substitute ini
's value instead, as demonstrated here:i <- "E. coruscans" xyplot(1:10~1:10, main = substitute(expr = expression(paste("Species name: ", italic(i))), env = list(i=i)))