# PDFLaTeX produces black boxes after executing Sweave

There is the following code

\documentclass[a4paper]{article}

\begin{document}

hey there

<<>>=
1+1
@
\end{document}


I saved the example.Rnw in my home directory an then I executed the .Rnw with Sweave("/home/myname/example.Rnw") in R using the terminal.

The output is:

Writing to file example.tex
Processing code chunks with options ...

You can now run (pdf)latex on ‘example.tex’


When I open the generated tex-file with the Texmaker, it looks like this:

\documentclass[a4paper]{article}

\usepackage{Sweave}
\begin{document}

hey there

<<>>=
1+1
@
\end{document}


I think, at this point the tex-file has to be look different!

When I run PDFLaTeX on the file. The results are little black boxes. << and >> are the black boxes following by the statement = 1+1 @

What could be wrong?

-

You should not indent code chunks -- Sweave does not allow that. You can use knitr instead (run library(knitr); knit('yourfile.Rnw') instead of Sweave('yourfile.Rnw')).
Ok it works, this way. Thank you! I just followed the Sweave documentary and usually it has to work. I don't know what's wrong. May be something with my system configurations. The knitr package looks good so far. Thanks for the proposal. With R I can connect to my PostgreSQL database. Can I do this with knitr as well? – Stefan Mar 15 '13 at 8:59
@user15459 You can do whatever you can as long as it works in R since knitr is an R package. – Yihui Mar 15 '13 at 17:17