[R] infix paste and package

Duncan Murdoch murdoch.duncan at gmail.com
Thu Jun 19 18:15:45 CEST 2014


On 19/06/2014, 3:10 PM, Christian Hoffmann wrote:
> Hi,
> 
> I can successfully define  in .R and in  > R
> 
> "%&%" <- function(a,b) { paste(a,b,sep="") }
> 
> nd use in R >
> 
>   "a" %&% "b"
> [1] "ab"
> 
> but in a package definition .Rd
> ....
> \name{pasteInfix}
> \alias{pasteInfix}
> \alias{\%&\%
> }
> \usage{ a  \%&\% b
> }
> 
> will fail in R CMD   check --as-cran  saying
> 
> "I am" %&%
> +  " hungry" # [1] "I am hungry"
> Error: could not find function "%&%"
> Execution halted.
> 

Since % is a comment marker in .Rd files, you need to be quite careful
how you enter them.  I would look at examples in the R sources, e.g.

http://svn.r-project.org/R/trunk/src/library/base/man/match.Rd

Duncan Murdoch

> What is wrong in my .Rd file?
> 
> PS:  The placement of the closing } and the escaping of "%" seem also 
> critical.
> 
> TIA  Christian
>



More information about the R-help mailing list