[R] \examples{} in Rd file

Prof Brian Ripley ripley at stats.ox.ac.uk
Sun Jan 16 13:51:00 CET 2011


On Sun, 16 Jan 2011, Peter Ehlers wrote:

> Adelchi,
>
> Since % is the LaTeX comment character, you may want to
> try escaping it.

As package 'base' does at
https://svn.r-project.org/R/trunk/src/library/base/man/matmult.Rd

> Peter Ehlers
>
> On 2011-01-16 02:35, Adelchi Azzalini wrote:
>> [Hope this is the right list where to send...]

Either R-devel or this -- I would probably send questions about 
preparing packages to R-devel as you are more likely to catch the 
attention of active developers there.

>> An attempt to update package 'mnormt' involves the addition of a
>> small new function called 'pd.solve'.  When I come to the package
>> checking stage, an error occurs in parsing  pd.solve.Rd.
>> The full transcript of the outcome is copied below (it includes details
>> on my installation) but the critical point is where the \examples{}
>> section includes a %*%. The relevant portion of the source file is
>> 
>> \examples{
>>     x<- toeplitz(rev(1:4))
>>     x.inv<- pd.solve(x)
>>     print(x.inv %*% x)
>>     logDet<- attr(x.inv, "log.det")
>>     print(abs(logDet - determinant(x, logarithm=TRUE)$modulus))
>> }
>> 
>> which leads to the message
>>
>>    ### ** Examples
>>   >
>>   >    x<- toeplitz(rev(1:4))
>>   >    x.inv<- pd.solve(x)
>>   >    print(x.inv
>> +   logDet<- attr(x.inv, "log.det")
>> Error: unexpected symbol in:
>> "  print(x.inv
>>     logDet"
>> 
>> When I install the package, it works, except that the documentation
>> portion looks like:
>> 
>> Examples
>> x<- toeplitz(rev(1:4))
>> x.inv<- pd.solve(x)
>> print(x.inv
>> logDet<- attr(x.inv, "log.det")
>> print(abs(logDet - determinant(x, logarithm=TRUE)$modulus))
>> 
>> It seems that the examples are parsed as ordinary text, not R commands.
>> I am really puzzled. Any explanation?
>> 
>> Adelchi Azzalini
>> 
> [... snip ...]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list