Sweave, hide the code

#1
Hey, I'm trying to use Sweave to make a report. I thought I could just use the command echoe=FALSE, but I still get my R code in the output.


\begin{center}
<<fig=TRUE,echoe=FALSE>>=
temp=read.table("my.txt",header=T)
plot(temp$x,temp$y)
@
\end{center}
 

bryangoodrich

Probably A Mammal
#2
Do you get the R output (e.g., the plot) or just the code you put in? Don't you have to put in a statement saying you're beginning a code section?
 

Lazar

Phineas Packard
#3
Hey, I'm trying to use Sweave to make a report. I thought I could just use the command echoe=FALSE, but I still get my R code in the output.


\begin{center}
<<fig=TRUE,echoe=FALSE>>=
temp=read.table("my.txt",header=T)
plot(temp$x,temp$y)
@
\end{center}
Typically you would save the graph as a PDF and then call it later. for example
Code:
<<echo=false , results=hide>>=
temp=read.table("my.txt",header=T)
pdf ( file=" myPlot. pdf " , width=6, height=5)
plot(temp$x,temp$y)
dev.off ( )
@
Then just write your /begin {figure} /includegraphics script in LaTeX for as you normally would. Make sure your include graphic command calls the PDF with the same width and height as you saved in the R pdf command :)
 

trinker

ggplot2orBust
#4
Try this. I think the problem is with your latex portion of the code.

Code:
\begin{figure}\label{figure:something sweet alright}
\begin{center}
<<fig=TRUE,echoe=FALSE>>=
temp=read.table("my.txt",header=T)
plot(temp$x,temp$y)
@
\caption{Some caption you want the world to know.}
\end{center}
\end{figure}
otherwise what's to tell latex you've got a figure?
 

Lazar

Phineas Packard
#5
Byran's point is an excellent point which is why I sweave in R studio. You should be able to check your R code and see if it returns the results you want (easy to do in Rstudio). If it does, then the problem is with your LaTeX or sweave specific commands.
 

trinker

ggplot2orBust
#7
Dason said:
And you might want to try "echo = FALSE" instead of "echoe = FALSE"
Ahh, I bet you're right that is the problem.

MaxMAn when you test out the solution(s) please let us know the outcome.
 
#8
The portion that says fig = TRUE.

And you might want to try "echo = FALSE" instead of "echoe = FALSE"
:p

Thanks, it was the typo. Strange it doesn't give an error message.

And of course thanks to everyone who tried to help and gave me more information about Sweave, R and Rstudio(I will download it when I'm finished with my homework)