Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>Update</em>:</p> <ul> <li><strong>.R files:</strong> <code>source</code>'s option <code>print.eval=TRUE</code> will lead to printing behaviour of the evaluation result like in the interactive command line.</li> </ul> <blockquote> <p><code>source("Script.R", print.eval=TRUE)</code></p> </blockquote> <ul> <li><strong>.Rnw files:</strong> <code>knitr</code> by default emulates the behaviour of the interactive command line wrt. <code>print</code>ing. Note that <code>knitr</code> can be specified as Sweaving engine also for R package vignettes.</li> </ul> <p><hr> <em>This is my original answer. But note that this workaround is IMHO completely obsolete now (and it always was good for a small lazy niche only).</em></p> <p>This is the famous <a href="http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f" rel="noreferrer">FAQ 7.22: Why do lattice/trellis graphics not work?</a>.</p> <p>For grid graphics like ggplot2 or lattice, you need to print the graphics object in order to actually draw it. </p> <p>Interactively on the command line this is done automatically. Everywhere else (inside files to be sourced, loops, functions, Sweave chunks) you need to print it explicitly.</p> <pre><code>print (qplot (1 : 10, 1 : 10)) </code></pre> <p>Alternatively, you can redefine <code>qplot</code> to do the printing:</p> <pre><code>qplot &lt;- function (x, y = NULL, z = NULL, ...) { p &lt;- ggplot2::qplot (x = x, y = y, z = z, ...) print (p) } </code></pre> <p>(this changes the axis labels to x and y).</p> <p>I use this approach in vignettes where I want to write code exactly as a user in an interactive session would type it.</p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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