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

From: Duncan Murdoch <>
Date: Sat, 16 Feb 2008 17:15:35 -0500

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 mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Sat 16 Feb 2008 - 22:21:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 17 Feb 2008 - 17:30:15 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive