[R] How to use a reserved word in italics in an expression

Duncan Murdoch murdoch at stats.uwo.ca
Sat Feb 16 23:15:35 CET 2008


On 16/02/2008 4:51 PM, Michael Kubovy wrote:
> Dear R-helpers,
> 
>  > label2 <- expression(paste(italic(attraction function:), 'slope'))
> Error: unexpected 'function' in "label2 <-  
> expression(paste(italic(attraction function"
> 
> How do I tell R that in this case I don't want 'function' to be  
> treated as a reserved word but as a string in italics?

Just put it in quotes.  In fact, I think italic("attraction") looks 
better than italic(attraction), so you may want to do this more generally.

For example,

plot(1, main=expression(paste(italic("attraction function: "), "slope")))

Duncan Murdoch



More information about the R-help mailing list