equations in R function documentation using Roxygen2

6,010 views
Skip to first unread message

Jane

unread,
May 26, 2015, 7:38:43 PM5/26/15
to davi...@googlegroups.com
Dear R users,

This is the equation that I want to put in when documenting an R function: $Beta(\alpha c_{ij}+\beta, c_{ij}+\beta)$

I used Roxygen2 when documenting functions. To add an equation in documentation, one should use \eqn or \deqn. Hadley explains in his R packages:

Mathematics

You can use standard LaTeX math (with no extensions). Choose between either inline or block display:

  • \eqn{a + b}: inline equation.

  • \deqn{a + b}: display (block) equation.


This is what I put in the documentation: \eqn{Beta(\alpha c_{i,j} +\beta, c_{i,j}+\beta)}

After running devtools::document(), it appeared in the help file like this: Beta(α c_{i,j} +β, c_{i,j}+β)

Any idea on how to make the subscripts work?

Thanks,
Jane

Michael Hannon

unread,
May 26, 2015, 8:06:36 PM5/26/15
to davi...@googlegroups.com
The following asserts that the LaTeX stuff works (fully) only in PDF output:

http://stackoverflow.com/questions/22918797/subscript-of-math-equation-in-r-documentation

Are you looking at PDF or at HTML?

-- Mike
> --
> Check out our R resources at
> http://www.noamross.net/davis-r-users-group.html
> ---
> You received this message because you are subscribed to the Google Groups
> "Davis R Users' Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to davis-rug+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/davis-rug.
> For more options, visit https://groups.google.com/d/optout.

Jane

unread,
May 26, 2015, 8:10:50 PM5/26/15
to davi...@googlegroups.com
I'm looking at both PDF and the R help file.

Jane

unread,
May 27, 2015, 1:28:07 PM5/27/15
to davi...@googlegroups.com
Thanks Mike!

The PDF output worked! Here's what I used. \eqn{Beta(\alpha c_{i,j} +\beta, c_{i,j}+\beta)}

But the R help file output still looks a little messy. I used {Beta*(\alpha * c_ij + \beta, c_ij + \beta)}, and the output is Beta*(α * c_ij + β, c_ij + β).

I looked up math equations displays from other packages, most of them look somewhat messy. I decided not to spend too much time on it. 

It would be great if anyone happen to know how to fix this, please do let me know!

Thanks!

On Tuesday, May 26, 2015 at 5:06:36 PM UTC-7, Michael Hannon wrote:
Reply all
Reply to author
Forward
0 new messages