Note that there are some explanatory texts on larger screens.

plurals
  1. POChange default prompt and output line prefix in R?
    text
    copied!<p>For the purposes of teaching and preparing written instructions about R, one of the things that's always frustrated me is that I can't simply copy commands and output from R and paste them into another R session. For example, if I do something trivial, such as</p> <pre><code>&gt; x &lt;- rnorm(10) &gt; x [1] 1.76975998 1.19722850 -0.39274507 -1.10979974 0.52320473 -0.08643833 [7] 0.94437690 0.08083207 0.62260363 1.89305469 </code></pre> <p>If I copy and paste that into a document or even here in this post, you (and my students) can not then just highlight it, copy it and paste it into an R session successfully</p> <pre><code>&gt; &gt; x &lt;- rnorm(10) Error: syntax error &gt; &gt; x Error: syntax error &gt; [1] 1.76975998 1.19722850 -0.39274507 -1.10979974 0.52320473 -0.08643833 Error: syntax error &gt; [7] 0.94437690 0.08083207 0.62260363 1.89305469 Error: syntax error </code></pre> <p>You might want to do this to test your installation of R, compare my output to yours, or simply to make use of a function I've offered.</p> <p>So, what I'd like to be able to do is to change the default prompt from > to either an empty string or a blank space and also prefix all output lines with a hash mark #. That way, I could use R interactively to generate a session that looks like</p> <pre><code>x &lt;- rnorm(10) x # [1] 1.76975998 1.19722850 -0.39274507 -1.10979974 0.52320473 -0.08643833 # [7] 0.94437690 0.08083207 0.62260363 1.89305469 </code></pre> <p>which <em>could</em> be copy/pasted into an R session successfully. It would make prepping R code for a journal article, students, lectures, etc. much easier for me (and maybe for others?)</p> <p>I've poked around the documentation with no luck... any ideas? pointers?</p> <p>Currently, I'm using R on a Mac either via the R.app GUI or from Terminal.</p>
 

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