Note that there are some explanatory texts on larger screens.

plurals
  1. POEmbedding ggplot2 output in LaTeX pdf using knitr and RStudio
    primarykey
    data
    text
    <p>In the past, I've used RStudio to create ggplot2 and then exported them as PDFs from within RSudio. This works fantastically.</p> <p>I'm now trying to automate using knitr, but I'm having trouble figuring out where to set the graph height and weight to create high quality output.</p> <p>Here is my current attempt, but the "side by side" graphs aren't, the rotated landscape graph isn't, and the resolution seems low.</p> <p>I'd appreciate any advice. It seems that both ggplot2 and knitr are under active development, which is great, however, internet searching has led my astry. LaTeX is new to me. I'd also appreciate any general workflow strategies for this set of tools. Thanks in advance.</p> <pre><code>\documentclass[letterpaper]{article} \usepackage{lscape} \begin{document} &lt;&lt;load, echo=FALSE, results='hide', warning=FALSE, message=FALSE&gt;&gt;= require(ggplot2) @ Two on the first page. &lt;&lt;first, echo=FALSE, fig.height=3, fig.cap="This is first", fig.pos='h'&gt;&gt;= ggplot(mtcars, aes(mpg, wt))+geom_point()+facet_grid(vs ~ am, margins=TRUE) @ Blah, blah, blah. &lt;&lt;second, echo=FALSE, fig.height=3, fig.cap="This is second", fig.pos='h'&gt;&gt;= ggplot(mtcars, aes(mpg, wt))+geom_point()+facet_grid(vs ~ am, margins=TRUE) @ \newpage Second page. Side by side images: &lt;&lt;third, echo = FALSE, out.width="2in", fig.cap='Side by side'&gt;&gt;= ggplot(mtcars, aes(mpg, wt))+geom_point()+facet_grid(vs ~ am, margins=TRUE) ggplot(mtcars, aes(mpg, wt))+geom_point()+facet_grid(vs ~ am, margins=TRUE) @ \newpage \begin{landscape} This page is rotated &lt;&lt;fourth, echo = FALSE, out.width="4in", fig.cap='Landscape'&gt;&gt;= ggplot(mtcars, aes(mpg, wt))+geom_point()+facet_grid(vs ~ am, margins=TRUE) @ \end{landscape} \end{document} </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload