[R] extracting items from R objects and using them in \Sexpr with Sweave--problem with $
Christopher W. Ryan
cryan at binghamton.edu
Thu Nov 29 20:45:35 CET 2007
Running R 2.5.1 on WinXP with Tinn-R, and using Sweave via MikTex.
I am having trouble with the code below:
-------------------------------------------------------
<<lowerCI95>>=
lowerCI95713 <- t.test(data713, alternative="greater")
lowerCI95713.bound <- lowerCI95713$conf.int[1]
@
Thus a lower 95\% confidence bound on the mean octane concentration is
\Sexpr{lowerCI95713.bound}.
<<ttest>>=
t.test713 <- t.test(data713, mu=87, alternative="greater")
p.value <- t.test713$p.value
@
---------------------------------------------------------
When I Sweave and then pdflatex the files, the output pdf file contains
the verbatim text:
"Thus a lower 95% confidence bound on the mean octane concentration is
lowerCI95713.bound."
That is, LaTeX is not recognizing and processing \Sexpr. When I look at
my .tex file in an editor with LaTeX syntax highlighting, I see that
LaTeX is interpreting everything between the two $ in the original code
(one before conf.int and one before p.value) as a math environment. I
think that's why the \Sexpr is not getting processed into the single
number as it should.
Any ideas how to make this work? The $ is the only way I know how to
access components of R objects.
Thank you.
--Chris
--
Christopher W. Ryan, MD
SUNY Upstate Medical University Clinical Campus at Binghamton
40 Arch Street, Johnson City, NY 13790
cryanatbinghamtondotedu
PGP public keys available at http://home.stny.rr.com/ryancw/
"If you want to build a ship, don't drum up the men to gather wood,
divide the work and give orders. Instead, teach them to yearn for the
vast and endless sea." [Antoine de St. Exupery]
More information about the R-help
mailing list