[R] Rd: how to put a prime in a code fragment?

Duncan Murdoch murdoch at stats.uwo.ca
Sat Apr 18 15:19:43 CEST 2009


On 18/04/2009 8:49 AM, Dan Kelley wrote:
> I have written a function for my 'oce' package that creates a data.frame
> containing a variable name with a prime in it.  (I use prime to indicate
> coordinate rotation, a reasonably standard convention that motivates the odd
> variable name.)
> 
> How can I name that in an Rd file?  I tried \code{u'} but R-2.9.0 doesn't
> like to build my package then, since it thinks I'm opening a string.  So I
> tried \code{u\'} but then the backslash appears in the documentation.

The new convention is that \code{} contains legal R code (with a few 
exceptions for markup).  You can use \preformatted{} or \samp{} for 
verbatim text.  So \preformatted{u'} should display the way you like.

If you are using u' as a variable in R, you'd have to enter it as `u'`, 
and that should also be accepted in \code{}.

This stuff is in transition in 2.9.x; 2.10.x should make it all a bit 
cleaner, when the old somewhat inconsistent rules are no longer the default.

Duncan Murdoch




More information about the R-help mailing list