Home Comments Thread
New Thread

5 Comments

giscus-bot giscus-bot 2022-12-16 23:02:56
Guest *Statisfactions* @ 2013-01-27 02:05:21 originally posted:

The only thing I would add: test your code in the form that it appears in your post, also! Anyone who puts "smart quotes", en-dashes, or other monstrosities in their posted code shall be held legally liable for all the severe psychological harm they cause in their beleaguered readers.

yihui yihui 2022-12-16 23:03:00

Oh, yes, definitely!! There are people who write code in Word... or Wordpress but put code in

instead of
...

Originally posted on 2013-01-27 06:38:27

giscus-bot giscus-bot 2022-12-16 23:02:57
Guest *Gavin Simpson* @ 2013-01-27 10:23:47 originally posted:

In my case, I use the prompt in code when I want to show the input and output from R as a sort of transcript that the user can follow along with. When I'm just posting code to run, I do it without the prompt.

Another reason people might post code with the prompt is that teachers tend to abhor the "copy-paste" mentality; it is important to learn to enter R code too so you understand the importance of aspects of the language.

In written documentation intended for printing where R is used as a tool to do something else, I find it quite helpful to have the prompt and output interspersed as it helps demarcate the code from the body text and provides visual clues that the reader can identify when running R.

yihui yihui 2022-12-16 23:03:01

For the purpose of demarcation/visual clues, I'm highly opinionated as I said in the end of this post: shading is a much better choice than prompts. It seems to be a convention on the web nowadays to put code in light gray boxes, e.g. (the twitter bootstrap style) http://www.maths.lancs.ac.uk/~rowlings/Teaching/UseR2012/crime.html

Originally posted on 2013-01-27 20:39:18

giscus-bot giscus-bot 2022-12-16 23:02:58
Guest *Feng Li* @ 2013-01-29 09:47:58 originally posted:

Interesting stuff.

I am not very sure I agree with you 100%. For sure there is annoyance having the dollar everywhere. But it also tells you who you are, i.e. # tells you that you are root now and $ tells you you are a regular user. Besides I usually want to have user@machine:pwd$ style. That will save me a lot time when I am working with clusters and a lot machines but not get confused.

Also having the prefix is to tell you not to try it (I mean by simply copy and paste) unless you know what you are doing. As it may harm your machine. Think about a newbie comes to a forum and asks how to fix a specific problem, then some jerk replied:

sudo rm /

Similar thing applied in R. The prefixes ">", "+", "browser[1]>" tell the status of the R horse.

About the color thing. It is fancy but it is bad also. First, highlighting will slow down the console when you have a big buffer of output/code. Second it is more troublesome for the colorblind people.

BTW believe or not the more $ you have, the richer you will be. I have € in my console.

good day, mate!

@feng-li

yihui yihui 2022-12-16 23:03:02

I agree with everything you said when you are in the console, but what I was complaining about was when we are not in the console, e.g. when you pass a shell script to other people -- you should make it directly usable instead of letting them remove the damn extra dollars.

sudo rm / is an extreme case; what is more, you cannot really stop people (either silly or careless enough) running such code by add $ before it.

Originally posted on 2013-01-29 19:17:08

giscus-bot giscus-bot 2022-12-16 23:02:59
Guest *Erdogan CEVHER* @ 2016-12-05 20:23:35 originally posted:

I COMPLETELY agree with you Yihui. I come to this conclusion after many coding. Unfortunately, being new to R a couple years ago, and know nothing about knitr, tikzDevice, I repeated this error (polluting the code) in my first paper.
I am very very upset now. I will never repeat this error once more.

giscus-bot giscus-bot 2022-12-16 23:02:59
Guest *Elliot Marsden* @ 2017-11-14 18:05:51 originally posted:

I've been frustrated by this problem as the code-copier, but didn't connect the dots when I was the code-writer, to realise that it would frustrate readers. I'll remember now though!

Sign in to join the discussion

Sign in with GitHub