[R] Displaying Equations in Documentation

Rolf Turner r.turner at auckland.ac.nz
Mon Aug 25 22:43:45 CEST 2008


On 26/08/2008, at 4:50 AM, Jarrett Byrnes wrote:

> 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}

	

	Displays, presumably, in a plain text or html environment.

	As my late Uncle Stanley would have said, ``What the hell do you  
expect?''

	Plain text and html, unlike LaTeX, do not have advanced mathematical  
display
	capabilities.

	The R documentation facility --- RTFM!!! (section 2.6 Mathematics)  
--- provides a way
	to allow for both possibilities.  You can do:

	\deqn{R^2 = 1 - \frac{estimated variance}{observed variance}}{R- 
squared = 1 - (estimated variance)/(observed variance)}

	Then in the pdf manual for your package you'll get the sexy  
mathematical display, but when you call
	for help on line and get a plain text or html version you'll see

		R-squared = 1 - (estimated variance)/(observed variance)

	which is the best that can be done under the circumstances		
>
> I have also tried
>
> \deqn{R^{2} = 1-\frac{{estimated variance}{observed variance}}}
>
> and
>
> \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?

	Yes.

		cheers,

			Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}



More information about the R-help mailing list