17

I mainly post under the r tag and in most cases the sample data is given in a poor format, mostly a copy paste of the output of the table, with no date or character formatting, sometimes a picture, sometimes nothing...

The usual scenario is that an answerer will reformat it in their answer, and others answers will copy it from there.

Seems to me it would make more sense to edit it into the question than post it as a footnote to your answer, but no one does this and I've followed this unwritten rule like a good sheep so far.

Is there any good reason why this isn't done or shouldn't be done ?

I would go as far as suggesting that adding sample data to a question when there wasn't any in the first place, if one is confident that they understood the question perfectly, would be valuable if you're the first answerer, as it's much more readable and smooth to read a batch of answers based on the same data.

Before I start acting on these thoughts however I'd like to hear yours.

8
  • 1
    I try to make the asker do that work by making them aware of this (convincing and polite, in my opinion) link: meta.stackoverflow.com/questions/333952/… Admittedly a different technology, but the idea is the same and can be "transposed" with some polite explanation.
    – Yunnosch
    Commented Jul 12, 2018 at 20:47
  • and what is your success rate :) ? Commented Jul 12, 2018 at 21:05
  • 4
    Yes I have had successes. More than one. Yes. Surely. Please do not ask more details or I start to wimper.
    – Yunnosch
    Commented Jul 12, 2018 at 21:06
  • 2
    Please don't, you're changing lives :). Though seriously I believe having nicely formatted question around has an influence on what format the next users will choose, if it's messy copy and pastes of output everywhere I understand why the next guy won't try to do better. And it's also more education about how to do it right. Commented Jul 12, 2018 at 21:19
  • You should not edit the sample data, that is, add or remove information since you could have a different perspective than the author of the question wanted to say. That type of modification will not be accepted. You should suggest that it improve, if the asker is interested in solving your problem he will understand you and will want to improve it.
    – eyllanesc
    Commented Jul 13, 2018 at 3:34
  • 1
    I would very rarely change the information though. I would just make the issue easier to reproduce. Commented Jul 13, 2018 at 6:17
  • I think for r questions anything you can do to make it more readable is helpful. Yes sometimes I try to get them to do it, but if they are a new user or if I think I can answer the question right away then I'll do it.
    – Elin
    Commented Jul 14, 2018 at 16:03
  • 1
    I think your title is misleading here—but I'm not 100% sure. Are you just asking whether it's acceptable to edit the question to reformat the sample data, or wrap it in something that makes it easy to copy and paste into an interpreter, etc.? Or are you asking whether it's acceptable to edit the question to actually edit the data? Because the two will (or at least should) get very different answers, and in fact you seem to already be getting both kinds of answers here.
    – abarnert
    Commented Jul 14, 2018 at 21:44

6 Answers 6

8

I see SQL questions with poorly formatted data edited often by others, especially from newbies who don't take the time or effort to format and/or learn the markdown. I have never seen the content changed, only the formatting. This includes not only the data, but the schema also: table & column names, relationships, etc. The same goes for SQL statements and even some code. If for some reason such an edit would substantially change the meaning of the data (which I've never seen), the original poster has opportunity to see it, correct and improve it. At the least they see a good example of how the data could and should be presented. (Of course one should be aware if the issue could be caused by typos and the like, and that editing could remove such important evidence. But as I said, I've never seen such a scenario or problem with good-faith edits.)

I'll admit that I don't think such edits should be made after others have already answered, or if the question is from high-rep user who should know better, or perhaps purposefully presented it in a certain way.

For very sloppy or confusing data, I usually kindly ask the OP in comments to reformat the data themselves before I'll contribute, especially if I see that the question is being downvoted. I personally won't take the time to clean up after someone else, but that's just my own principle that I expect new users to learn how to do it. If they don't comply, I might also vote it down and then move on.

Overall I don't agree with the apparent ethical concerns of others since 1) no sensitive data should be posted anyway, 2) technically code and text are just a form of "data" and they are editable, 3) by posting on Stack Exchange the OP essentially consents to releasing the data as part of the question and should expect that it's open for edit just as anything else, and 4) it goes along with the intent of SO to mutually improve the question to make it better for everyone. Any abusive edit would be apparent and would fall under the basic code of conduct (i.e. be nice and/or the new code they're developing) and could be handled in the normal fashion.

8

Beyond readability, I wouldn't advise editing someone's data in the question; it is a very grey area.

There are a decent amount of assumptions required to alter data being used as an example in a question. It is probably best to instead leave the data as shown in the post, and allow the interpretation and response to live in the answers.

2
  • 3
    OP is really talking about reformatting not changing.
    – Elin
    Commented Jul 14, 2018 at 16:03
  • 1
    @Elin - No. "it would make more sense to edit it into the question" the OP states. Changing the tabs and spaces is fine, hopefully the OP wasn't asking if they can use the already built in tool for indenting code. I am specifically stating do not edit data into questions, in almost no circumstance is this a good idea.
    – Travis J
    Commented Jul 15, 2018 at 10:18
6

Cleaning up the format? Absolutely.

I'd put this in the same category of ctrl-K-ing code, removing excess white space, trimming of (unused stub) methods1, and other sorts of code formatting which are considered Acceptable Edits to Code.

Changing the data, however, is not acceptable.

However, if the data contains potentially sensitive information (e.g. real phone numbers, passwords, email addresses, etc), that should be flagged (custom) so that a mod can edit without leaving the original sensitive information in the edit history.

1 Most applies to questions where new users will post code that contains the default empty Start() and Update() methods that Unity uses for its MonoBehaviour class template.

5

Sometimes, the answer has to be "No". It simply isn't clear what the user wants and their sample data does not make it clear what algorithm, if any, is to be used. A case in point — Nested loop for loop (now only visible to 10k users). (No, it isn't a good question, not least because they've not shown what they've tried to do.)

The data shown is:

2 - - - - -
-4 - - - -
- -6 - - -
- - -8- -
- - - -10-
- - - - - 12

While there are many ways that the data could be cleaned up, it is not remotely clear which of the options is correct. From the first three lines, it appears that the numbers are left justified in a width of two, or perhaps printed with 'natural' width and a trailing blank. However, the other three lines all deviate from that in various ways. The line with 10 does fit 'two digits left justified'; the other two are simply different. And it is not clear what the requirements really are.

This is meant to be the output from a program rather than the input; that's slightly different from what this question asks about, but it is very closely related.

In things like shell scripting and Awk and related topics (e.g. CSV format, especially when it is tab-separated rather than comma-separated), spaces vs tabs can be very important and very tricky.

Extreme caution is required. Sometimes, you can change the format without affecting the question; sometimes you can't.

2

I have added to questions with a one-line dput if I was interested enough in the question to answer and copy the data into a usable format. Sometimes I hope this can lead to other answers from more experienced users as well. I think it's uncommon that I edit out the original way data was presented, though.

2
  • I think adding a dput and not removing anything from the post is probably the most harmless way of doing it, I tend to dislike dput as it's not very readable and horrible to copy and paste, but nevertheless, balancing all comments and considering dput is pretty uch the official recommendation, i think that'd be the way to go. I'd accept this answer if I had tagged that question as an [r] question. Commented Jul 14, 2018 at 16:13
  • Usually I dput, then remove all the newlines, then use styler to remove the extraneous spaces so it all fits on one line. It'd definitely be nice if there was a simpler way to do it, though.
    – Calum You
    Commented Jul 14, 2018 at 21:57
2

I certainly agree that it's a good idea to reformat the sample data (assuming of course that the reformatting doesn't alter the question). Ideally, we get the OP to reformat code and data, but that's not always practical when the OP is a newbie unfamiliar with SO standards and the SO editor. It can be quicker to just do it yourself than to try & teach the OP what needs to be done via comments. And we want it done ASAP so that the answers using that data are uniform.

But even if the reformatting isn't done quickly it should still be done at some stage, if the question is worth answering. If it's roomba fodder, don't waste time on it. Good looking questions don't necessarily inspire other OPs to post good looking questions, but bad looking questions certainly can promote the posting of more poorly-formatted questions, according to Broken Windows theory.

Of course, sometimes it's impractical for us to fix the OP's data, typically because it's in the form of a screenshot of a spreadsheet. But IMHO such questions should be put on hold with the "No MCVE" close reason if the OP fails to post proper data in text form when requested.

However, I do not agree with modifying the contents of the data. Sometimes it's tempting to do that because the OP's data doesn't adequately exercise the code. In that situation you may be able to get the OP to improve their data. Otherwise, just use your own improved version in your answer. The danger is that you may have misunderstood the OP's intent (perhaps they haven't expressed it with sufficient clarity), so your changes to their data would fall under the "conflicts with the author's original intent" banner.

You must log in to answer this question.

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