Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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')).

share|improve this answer
    
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 B. 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.