Using R and Sweave to Incorporate Graphics in Latex Documents"

  • LaTeX
  • Thread starter MaxManus
  • Start date
  • Tags
    Latex
Reader for me too.In summary, the conversation is about using R and Sweave to create a document with Latex. The output includes a summary of cod data and a scatterplot, but when running Latex with MikTex, the plot appears empty. It is suggested to use pdflatex to compile and view the document in Acrobat Reader for proper rendering of graphics.
  • #1
MaxManus
277
1
I'm trying to use R and Sweave to make a document. This gives the Latex;
\documentclass[a4paper,norsk]{article}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel,textcomp}
\title{test}
\author{me}
\usepackage{Sweave}
\begin{document}


1a)

\begin{Schunk}
\begin{Sinput}
> summary(cod)
\end{Sinput}
\begin{Soutput}
length seas area age
Min. : 35.00 1:100 1:200 Min. : 2.00
1st Qu.: 55.00 2:100 2:200 1st Qu.: 5.00
Median : 64.00 3:100 Median : 6.00
Mean : 65.17 4:100 Mean : 5.87
3rd Qu.: 73.00 3rd Qu.: 7.00
Max. :134.00 Max. :13.00
\end{Soutput}
\end{Schunk}
\includegraphics{test-003}
dad




\end{document}

When I try to run Latex with MikTex it gives me a empty plot. Does anyone know why?

Edit: It seems like it's the "dots" in the scatterplots that are the problem. The finished latex document shows lines, but not dots. Does anyone know what to do?
 

Attachments

  • test-003.pdf
    302.7 KB · Views: 207
Last edited:
Physics news on Phys.org
  • #2
I used pdflatex to compile in MacTeX--TeXwork's (which I believe is also the default for MikTeX) built-in PDF reader garbles your graphic, but Acrobat Reader seems to render it just fine.
 
  • #3
Thanks, it showed in Acrobat
 

1. What is R and Sweave?

R is a popular open-source programming language and software environment for statistical computing and graphics. Sweave is a tool that allows for the integration of R code and output into LaTeX documents.

2. Why would I want to incorporate graphics in my LaTeX document using R and Sweave?

Using R and Sweave allows for the automatic generation of high-quality graphics and statistical analyses in LaTeX documents. This can save time and effort compared to manually creating and inserting graphics.

3. How do I use R and Sweave to incorporate graphics in my LaTeX document?

First, you will need to have R and LaTeX installed on your computer. Then, you can use the Sweave package in R to create a .Rnw file, which is a combination of R code and LaTeX markup. Once you have written your code and inserted any desired graphics, you can run the code in R and the output will be automatically incorporated into your LaTeX document.

4. Can I customize the appearance of my graphics using R and Sweave?

Yes, you can use R code to customize the appearance of your graphics, such as changing colors, labels, and formatting. This allows for greater flexibility and control over the appearance of your graphics in your LaTeX document.

5. Are there any limitations to using R and Sweave for incorporating graphics in LaTeX documents?

One limitation is that you will need to have some familiarity with both R and LaTeX in order to effectively use Sweave. Additionally, not all types of graphics and analyses can be easily incorporated into LaTeX using R and Sweave, so it is important to check the compatibility of your desired graphics beforehand.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
11K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
11K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
4K
Back
Top