I recently came across a question where a new user posted a question and attempted to provide reproducible data, originally posting (in the R language):
lon = c(0, 2.5, 5, 7.5, 10, 12.5, 15, 17.5, 20, 22.5, 25,...,360)
lat = c(17.5, 20, 22.5, 25, 27.5, 30, 32.5, 35, 37.5, 40,...,90)
This was not actually reproducible as anyone responding would have to fill in the ellipsis, or optimize the code using seq()
. But the user was a self-described "beginner" to R programming and didn't know.
If I were to answer, I would just make the adjustment in my answer. But I did not know the answer. To ease the work for other (better) coders that may know the answer, I considered editing the OP's code to actually produce the desired data. However, I was unsure if this was appropriate. I ultimately ended up recommending the OP change the code themselves (using seq()
- which they did change in the current version).
After searching the meta SO site, I came across several questions and answers that discussed revising and improving code in one's own answer (see Providing answers to code that is different, but more efficient than the OP's code or Is it okay to code-review and improve OP's code when posting an answer? or Should an answer refactor the user code?)
But these are not the same question, nor is my question about code optimization or the efficiency of the approach taken by the author. Specifically: is it ok to make minor edits to fix the code in the OP's question itself so that others in the Stack Exchange community don't have to debug?