# If OP asks for a software referral, and a referral *doesn't* exist, may we answer with the code they asked for?

If an OP asks for a R library recommendation (policy under debate in another meta thread, I realize), and no acceptable recommendation exists, what is the policy regarding writing and posting code that accomplishes what the OP needs? In case this is out-of-bounds, what is the in-bounds way of suggesting that the conversation move off CV?

This pertains to a recent request for survival analysis software to support data not (obviously) supported by the R library survival. There is now a bounty on this request, so I'm being egged on to do something.

• It would help if you would link to the threads that motivate your questions here for context. Are you referring to: Is there a standard way to treat events with unknown times (missing survival time data)? Mar 6 '19 at 21:52
• +1, to whuber & Tim's answers below. Be aware, however, that you are still free to attempt to help the OP & provide an answer in the interim anyway. Eg, you can vote to close as off topic, & nonetheless post an answer. (Nb, this advice pertains to off-topic Q's, not, say, unclear Q's, where an interim answer may make everything worse.) Mar 6 '19 at 21:54
• @gung, yes, I am referring to that one, but my question is (I think appropriately) general so that it qualifies as a meta. Mar 6 '19 at 22:18
• Your question certainly qualifies for asking on Cross Validated Meta. But it still helps to provide more specific context. You can ask the general question & link to the thread that motivates it. Mar 6 '19 at 22:26
• A bounty doesn't make a question on-topic or even good. It just means, usually, that the OP is willing to spend reputation in pursuit of an answer. (I've been frustrated sometimes that votes to close as off-topic or otherwise deficient aren't allowed while a bounty is on offer.) Note: Sometimes generous people offer a bounty on someone else's question, which they think is a good question. In those cases, it usually is a good question. Mar 7 '19 at 9:52
• @NickCox, be aware that you can flag such questions. If they need to be closed, we can refund the offered bounty to the OP & close the Q. Mar 7 '19 at 12:29
• @gung Wait! Wait! It seems to be the will of the community that the pedagogical quality of the ANSWER is what saves the question. You really shouldn’t close such questions until the answers have come in. Some answers take longer than others. Please don’t leave me stranded with an answer and no question. (That’s a Jeopardy nightmare. Shall we call that a Jeopardy case?) You can refund the reputation, but you can’t refund the time spent on a quality answer. Mar 7 '19 at 13:23
• @gung Indeed. But the thinking behind the inhibition seems to be that bountied questions should be left as is to take their chance, so I tend to hold back. If -- as has not happened in my experience, but it's a thought experiment -- someone posted an offensive question and bountied it, I would not hold back. Mar 7 '19 at 13:31
• @PeterLeopold That's a grey area. I agree with you that a good answer can save a thread. But how long are we supposed to wait for a good answer to do that? The main principle behind zapping poor questions -- and fairly promptly -- is that if the OP has a better question if they try harder to be clear and specific, then that's fine; otherwise we are not missing anything valuable. Mar 7 '19 at 13:34
• @NickCox How long to wait? The bounty period? Well, I’m new here, and if I find myself in a Jeopardy state (answer with no question) then I expect the moderators would encourage me to ask-answer a new question so I’m not all-dressed-up-with-nowhere-to-go. ;) Mar 7 '19 at 13:48
• Are you asking specifically about bountied questions? Or generally? I think you're asking about bountied questions and I am confusing the issue by commenting generally. As said, I wouldn't want to close a bountied question unless it was offensive or really bizarre. I once had, as a hypothetical and private example of a completely off-topic question, a question about personal relationships. But then one really did appear; it didn't last long and I wish sometimes I had kept a copy. Mar 7 '19 at 14:02
• @PeterLeopold, it is possible for an answer to save a question, but generally questions should be judged on their own merits. The time & effort to post an answer aren't necessarily wasted. 1) They can help the OP. 2) For off topic Qs that are migrated (eg, to Stack Overflow), the rep transfers there. 3) For off topic Qs that are closed, but stay here, you keep the rep, & if there is an upvoted answer, the thread is not deleted. The only way to lose is if the Q is subsequently closed w/o any upvotes or comments & the answer has no upvotes, then Q's that stay here will be automatically deleted over time. Mar 7 '19 at 14:20
• @Peter Waiting tends to be counterproductive, because during the wait period there is a relatively high likelihood that misleading or irrelevant answers will be posted. Experience teaches that putting a question on hold immediately is the best action to take when there is any concern about what a question is asking. On rare occasions users have flagged questions where they can offer a compelling interpretation and claim they have a good answer to offer; in such cases I have reopened those threads and I imagine other moderators have acted similarly to such flags.
– whuber Mod
Mar 7 '19 at 15:57

If code is the full answer to a question, then the question is off-topic. When the code illustrates or implements a statistical answer, such as a procedure or algorithm offered in response to a question about statistics or machine learning, then it is almost always warmly welcomed.

• OK, I will focus on how I can teach survival analysis by hand: minimize -log(likelihood) w.r.t. the parameters of the cumulative hazard function, which is should be on-topic, and then illustrate with code, etc. I indicated in my original answer that this is easier than making sense of poorly written manpages, anyway. Mar 6 '19 at 22:31

A question asking for software referral is not on-topic, unless it needs some kind of statistical expertise. The same applies to questions about code. So, for example, a question asking about R packages for reading Excel files, plotting social network data, or asking how to implement linear regression in Python, etc. would be off-topic.

On the other hand, asking how to translate some theoretical paper to some practical problem, including implementing it, would be on-topic.

The distinction is often blurry, but the general rule pivots on whether the question asks about programming or about statistics. For me, the easiest way to tell what kind of question it is would be to consider if the question could be answered using pseudocode, ignoring all the language-specific and implementational details. If it can't, it's about programming.

• I like your pseudo-code test, and as @whuber suggests, I will keep the focus on the pedagogy. Mar 6 '19 at 22:37

### Consider taking a long-term view and writing a new package

I speak here as someone who has done this quite a few times on this site. I have written three R packages (stat.extend, ts.extend and utilities) that largely came out of writing functions to solve problems from users who asked questions on this site. (Of course, all of these packages are quite general, and they do a lot more than answer the specific questions that initially motivated them, but that was the impetus for starting each of the packages.) I have answered a whole bunch of questions on CV and SE (see e.g., here, here, here, here, here, here, here, here, here, here, here, here, here, here, here, here, here, here, here and here) where the answer shows how to use one of those packages to solve the question at issue. In some cases, the question was asked before I had written the package, but it served as part of the motivation for creating the package. Writing these packages allows me to give simple user-friendly answers to all questions that ask for implementation of the kinds of problems in the original questions that motivated package.