Using R and Sweave to Incorporate Graphics in Latex Documents"

  • Context: LaTeX 
  • Thread starter Thread starter MaxManus
  • Start date Start date
  • Tags Tags
    Latex
Click For Summary
SUMMARY

This discussion focuses on the integration of R and Sweave for generating LaTeX documents that include graphics. The user encountered an issue where the scatterplot dots were not rendering in the final output when using MikTeX, although lines were visible. The problem was identified as related to the rendering of graphics, which displayed correctly in Adobe Acrobat Reader but not in the built-in PDF viewer of TeXworks. The user utilized the summary function in R to analyze data related to cod, demonstrating the functionality of R in conjunction with LaTeX.

PREREQUISITES
  • Familiarity with R programming language
  • Understanding of Sweave for integrating R code into LaTeX documents
  • Knowledge of LaTeX document structure and compilation
  • Experience with MikTeX or MacTeX for LaTeX processing
NEXT STEPS
  • Investigate the use of R graphics devices to troubleshoot rendering issues
  • Learn about alternative LaTeX packages for better graphic integration, such as 'graphicx'
  • Explore the differences between PDF viewers for LaTeX documents, focusing on compatibility
  • Research best practices for using Sweave with R for dynamic report generation
USEFUL FOR

Data scientists, statisticians, and researchers who utilize R for data analysis and need to produce high-quality reports with integrated graphics in LaTeX documents.

MaxManus
Messages
268
Reaction score
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

Last edited:
Physics news on Phys.org
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.
 
Thanks, it showed in Acrobat
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
13K
  • · Replies 1 ·
Replies
1
Views
8K
  • · Replies 4 ·
Replies
4
Views
12K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 2 ·
Replies
2
Views
5K