[R] Displaying Equations in Documentation

Jarrett Byrnes byrnes at msi.ucsb.edu
Mon Aug 25 18:50:01 CEST 2008

I'm currently working on writing up some documentation for some of my  
code, but am having the darndest time coding in equations.  For  
example, the equation in the following:

\details{ Calculated the R Squared for observed endogenous variables  
in a structural equation model, as well as several other useful  
summary statistics about the error in thoe variables.

R Squared values are calculated as

\deqn{R^{2} = 1-\frac{estimated variance}{observed variance}}

Standardized error coefficients are then calculated as sqrt(1 - R^2).

While it shows normally using R CMD Rd2dvi, when I actually compile  
and load the package, displays as follows:

R^{2} = 1-frac{estimated variance}{observed variance}

I have also tried

\deqn{R^{2} = 1-\frac{{estimated variance}{observed variance}}}


\deqn{R^{2} = \frac{1-{estimated variance}{observed variance}}}

with the same result - Rd2dvi is happy, but the display is still wonky  
in practice.  I've also tried subbing in \eqn{R^{2}} in the rest of  
the text in a few places, but, again, it shows as R^{2}.  Is there  
something I'm missing about inserting equations into R documentation?


More information about the R-help mailing list