3
$\begingroup$

I'm very grateful for the code function, as it makes it easy to illustrate some answers. Yet, I feel I for one have the risk of overloading my answer with R code. Good if you know R, but not always that easy to read for people not familiar with that language.

I answered this question recently and illustrated with a plot I drew quickly in R. I'd like to give the R code for it as well, but not in the text. Is there a way we could implement attachment of a code file? I could give it as a comment, but that looks so incredibly ugly...

So would it be feasible to allow attachment of -limited- code for illustration? If so, in which form could this be done?

$\endgroup$
8
  • $\begingroup$ What's the issue with using the code function? If someone does not know R they can just skip the code anyway and read the rest of the answer. That's what I do anyway as I do not know R. $\endgroup$
    – svadali
    Commented Sep 8, 2010 at 23:24
  • 2
    $\begingroup$ Or you can provide a link to the code somewhere else (eg github, google code, personal website). $\endgroup$
    – Shane Mod
    Commented Sep 9, 2010 at 3:09
  • $\begingroup$ @Srikant : In the question I linked to, you need to understand which distribution is made and which test is done to follow the answer. And I'd like to provide the code for reproducibility, as everybody can make mistakes. Otherwise I can make any plot I want and tell you it's something else (erroneously, let us assume nobody wants to cheat.) $\endgroup$
    – Joris Meys
    Commented Sep 9, 2010 at 8:29
  • $\begingroup$ @Shane : I could indeed, but I am not familiar with github / google code, and I'm not planning on a code database on a personal website. It would just be very nice to be able to add the code like you can add comments. $\endgroup$
    – Joris Meys
    Commented Sep 9, 2010 at 8:30
  • $\begingroup$ @Joris I understand why you want to give the code. But, I am confused why you think giving the code as part of the text itself is not helpful. Perhaps, you can give the code at the end of your answer using the code function so that it does not obstruct the flow of your answer. I guess my basic question is: what additional benefit would an "attachment functionality" above and beyond the benefits of the code function? $\endgroup$
    – svadali
    Commented Sep 9, 2010 at 14:16
  • $\begingroup$ @Srikant : with a bit of plot making, there's quite a bit of code. This would push other answers further down, lowering the chance they get read. OK, good for me as my answer takes away attention from others, but not a nice thing. I still believe adding the code is a valuable thing, as long as it stays out of the way from the real answer. $\endgroup$
    – Joris Meys
    Commented Sep 9, 2010 at 14:40
  • $\begingroup$ Does anyone know if the code function introduces scroll bars if the the code has too many lines? If it does then that may address the above concern to some extent. $\endgroup$
    – svadali
    Commented Sep 9, 2010 at 15:04
  • 3
    $\begingroup$ To answer my own question- a bit of an experiment shows that the code function introduces vertical scroll bars after 33 lines of code. So, massively long code will not increase the length of the answer which mitigates some of the concern mentioned above. $\endgroup$
    – svadali
    Commented Sep 9, 2010 at 15:16

2 Answers 2

6
$\begingroup$

There are some begs for "invisible" tag, so that the part of the question can be enclosed in "Show me more" link that expands into hidden content when clicked; I was initially against, but this may be a good argument that it is indeed needed; kilometers of code make the whole topic harder to read.

$\endgroup$
3
$\begingroup$

I would suggest to put extra code (e.g., that won't fit in an ordinary response) as dedicated Gist on Github. Don't know if you could manage to hold a public repository for the whole site or if each individual shall create his own account. Anyway, this is very great to share code snippets, with automatic syntax highlighting, revision history, with support for comments in Markdown.

$\endgroup$
1
  • 1
    $\begingroup$ +1, gist or any pastebin site is a great way to handle this. $\endgroup$
    – ars
    Commented Sep 12, 2010 at 6:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .