Monday, 12 August 2013

Include Iverson Bracket in R documentation

Include Iverson Bracket in R documentation

I am wanting to include an Iverson bracket in R documentation (unless
there's a better way to represent this information; I'm no mathematician).
This looks something like this.

Here I have valid LaTeX code for such an expression
w_{neg}=\left\{\begin{matrix}
1 & \sum{(X_i^{N})}>0 \\
0 & \sum{(X_i^{N}})=0
\end{matrix}\right.
I tried to include the code below:
#' w_{neg}=\left\{\begin{matrix}
#' 1 & \sum{(X_i^{N})}>0 \\
#' 0 & \sum{(X_i^{N}})=0
#' \end{matrix}\right.
in the details section of roxygen2 but it produces the error seen below
when compiling the pdf help documentation:
Creating pdf output from LaTeX ...
Warning: running command '"C:\PROGRA~2\MIKTEX~1.9\miktex\bin\texi2dvi.exe"
--pdf "Rd2.tex" -I "C:/R/R-30~1.1/share/texmf/tex/latex" -I
"C:/R/R-30~1.1/share/texmf/bibtex/bst"' had status 1
Error : running 'texi2dvi' on 'Rd2.tex' failed
LaTeX errors:
! Misplaced alignment tab character &.
<argument> \left \{\begin {matrix} 1 &
\sum {(X_i^{N})}>0 \\ 0 & \sum
{(X_i^...
l.5566 \sum{(X_i^{N}})=0 \end{matrix}\right.}{}
! Emergency stop.
<argument> \left \{\begin {matrix} 1 &
\sum {(X_i^{N})}>0 \\ 0 & \sum
{(X_i^...
l.5566 \sum{(X_i^{N}})=0 \end{matrix}\right.}{}
! ==> Fatal error occurred, no output PDF file produced!
Error in running tools::texi2pdf()
How can I include this Iverson Bracket in R documentation (unless there's
a better way to represent this in which case that's the better approach)?
Note that removal of these lines allows the package to compile.

No comments:

Post a Comment