Thaks Eric and Dieter: It is working now although I still have to specify the path to Sweave.sty \usepackage{C:/R/R-2.8.1/share/texmf/Sweave} and it doesn't evaluate \Sexpr{} when I simply use \usepackage{Sweave}. I placed Sweave.sty in the same folder where my rnw and tex file reside.
--- On Thu, 2/5/09, Eric R. <er...@mcs.st-and.ac.uk> wrote: > From: Eric R. <er...@mcs.st-and.ac.uk> > Subject: Re: [R] Sweave and \Sexpr{} > To: r-help@r-project.org > Date: Thursday, February 5, 2009, 1:03 AM > Felipe: > > See Leisch's FAQ A18. > > http://www.statistik.lmu.de/~leisch/Sweave/FAQ.html#x1-20000A.18 > > You likely have R2HTML loaded (likely because you are using > Tinn-R) and that > causes some difficulties for Sweave that are easily solved > as described in > the FAQ. > > > > Felipe Carrillo wrote: > > > > Hi: > > I am trying to create a dynamic latex table using > \Sexpr{} but it's not > > evaluating it. I also tried the example below without > Sweave and also > > fails. I have also copied the Sweave.sty to my working > directory but > > nothing seems to work. Do I need to have certain > package in order to run > > \Sexpr{}? > > > > \documentclass[a4paper]{article} > > \usepackage{C:/R/R-2.8.1/share/texmf/Sweave} > > \begin{document} > > > > <<echo=false,results=hide>>= > > library(lattice) > > library(xtable) > > data(cats, package="MASS") > > @ > > > > \section*{The Cats Data} > > > > Consider the \texttt{cats} regression example from > Venables \& Ripley > > (1997). The data frame contains measurements of heart > and body weight > > of \SExpr{nrow(cats)} cats > (\Sexpr{sum(cats$Sex=="F")} female, > > \Sexpr{sum(cats$Sex=="M")} male). > > > > A linear regression model of heart weight by sex and > gender can be > > fitted in R using the command > > <<>>= > > lm1 = lm(Hwt~Bwt*Sex, data=cats) > > lm1 > > @ > > Tests for significance of the coefficients are shown > in > > Table~\ref{tab:coef}, a scatter plot including the > regression lines is > > shown in Figure~\ref{fig:cats}. > > > > \SweaveOpts{echo=false} > > > > <<results=tex>>= > > xtable(lm1, caption="Linear regression model for > cats data.", > > label="tab:coef") > > @ > > > > \begin{figure} > > \centering > > <<fig=TRUE,width=12,height=6>>= > > > > print(xyplot(Hwt~Bwt|Sex, data=cats, > type=c("p", "r"))) > > @ > > \caption{The cats data from package MASS.} > > \label{fig:cats} > > \end{figure} > > \begin{center} > > \end{center} > > > > \end{document} > > > > > > Felipe D. Carrillo > > Supervisory Fishery Biologist > > Department of the Interior > > US Fish & Wildlife Service > > California, USA > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, > reproducible code. > > > > > > -- > View this message in context: > http://www.nabble.com/Sweave-and-%5CSexpr%7B%7D-tp21841963p21847606.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, > reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.