Note that there are some explanatory texts on larger screens.

plurals
  1. POR knitr - include graphics (ggplot2 object rendered in R code ) directly in a defined place
    primarykey
    data
    text
    <p>I am making my first steps with <code>knitr</code>, trying to generate a raport. In the raport, I include <code>R</code> code which generates a ggplot2 object that I want to be included directly below some text. To make it more detailed, the graphic is a pair of two separated plots, which I want to be placed parallelly, one next to another.</p> <p>So far, I have been dealing with by using the <code>R</code> code: producing and saving a .pdf picture, and then reading this picture from file and including it in the report by <code>\includegraphics</code> command. However, it is no more a solution for me - I want the <strong>plot to be generated simultaneously with the report by the <code>R</code> code</strong> (in particular: not to be saved anywhere as a .pdf)</p> <p>However, the code I tried to use did not work properly - it generates the 2 plots, but they are however:</p> <p><strong>1) incorrectly placed</strong> - 2 pages below (which is even not the end of the document!)</p> <p><strong>2) I don't know how to place them in one row, with the defined size</strong>.</p> <p>Please be of some help! Thank you in advance!! [below my not working porperly <code>R</code> code] </p> <pre><code>\textit{Pic 1 title} Some pic description \begin{figure}[h] \subfigure[pic1 name]{ &lt;&lt;echo = F, eval = T, message=F, fig=TRUE&gt;&gt;= # a function returning a ggplot2 object (with a proper parameters instead of "...") plot.matrix.from.file(...) @ % below there is a fragment of the code I used before (which includes a graphics directly from a .pdf file) %\includegraphics[scale=0.4]{data/simulated.data/obs_pred_mean_Gini_r.pdf} \label{pic1 label} } \subfigure[pic2 name]{ &lt;&lt;echo = F, eval = T, message=F&gt;&gt;= # a function returning a ggplot2 object (with a proper parameters instead of "...") plot.matrix.from.file(...) @ % below there is a fragment of the code I used before (which includes a graphics directly from a .pdf file) %\includegraphics[scale=0.4]{data/simulated.data/obs_pred_var_Gini_r.pdf} \label{pic2 label} } \caption{caption for the pair of plots} \end{figure} </code></pre>
    singulars
    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.
 

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