[R] Simple R (in Sweave) Question

Dieter Menne dieter.menne at menne-biomed.de
Mon Nov 3 08:48:29 CET 2008

dogle <DOgle <at> northland.edu> writes:

> I am writing a report using Sweave with specific R output incorporated into
> the text using the Sexpr{} command.  I have run into two specific issues:
> 1)  If the result inside the Sexpr{} command is an integer less than 10 I
> would like to print the “word” for that number – e.g., “seven” for 7.
> 2)  If a p-value is “equal to zero” to some arbitrary number of decimal
> places -- e.g., formatC(pvalue,format=”f”,digits=4) returns 0.0000 -- I
> would like to print “<0.00005”.

I try to avoid putting too complex things into Sexpr{}, because the text gets
unreadable. Normally I do the following (not tested), which should also work for
the "seven" example (put the texts into a vector for that)

(My default <<>> settting is hide)

p = 0.00001
myp = ifelse(p<0.001,"$p<0.001$",paste("$p=",round(p,1),"$",sep="\n"))

The probability of error is \Sexpr{myp}


More information about the R-help mailing list