# R questions 'on topic' for CV

I've looked at a number of previous discussions on the CV/SO divide for R questions - I'm not sure that any of those I've seen quite get to the following point:

There are now, I believe, getting on for 5,000 R packages - the astonishing growth representing the growth in interest and expertise in R evident here, as elsewhere, a diversity driven, in particular, by folks who are both experienced statistical pros and fluent coders.

There is often (not always, but often) an R function out there which will scratch the exact statistical itch that's bothering you right now, compared with the dozens of others that get only get close.

The problem is both that (a) the package-specific help is patchy and (b) there is no comprehensive source of information which matches R functions to itches - so tracking the right one down often depends on luck.

In many cases, what differentiates these functions is stuff that is 'under the hood' - that only those with a high level of expertise in both stats and R would easily grasp.

There are one or two sources of function comparison like this page for mixed models. But otherwise users are left guessing - and looking for help at SO or CV.

I've been monitoring answered questions with the R tag over at SO for a while: and they predominantly relate to function writing and data manipulation (plyr, reshape2, etc). They almost never talk about what's 'under the hood' of analysis functions like those in nlme and lme4 - I believe that such questions are deemed to be 'statistical' and therefore come under the remit of CV.

My question: is it generally agreed by those at CV that such questions are on topic? Clearly, CV is 'multi-platform' - although my impression is that, especially where examples (toy data, etc) are provided in questions or answers, R is the predominant language used.

On the other hand, what's 'under the hood' has (naturally enough!) a direct effect on the analysis CV-ers are doing. And those using SAS, Stata, etc. will surely have similar questions - so it wouldn't be a special privilege for R users.

• "getting on for 5,000 R packages" -- this is surely an underestimate, and I think by a substantial factor. There's nearly 5000 on CRAN, but CRAN is far from the only repository of R packages. – Glen_b Sep 20 '13 at 0:15

This issue seems to come up regularly in various forms, so it's clearly an issue where there isn't a perfect SE solution. With respect to what's on-topic on CV, my own decision process (for what it's worth--nobody is obligated to agree with me) is rather simple: what does the OP need explained to them? If the answer is a statistical concept, the question belongs on CV; if the answer is something about how R works / how to work with R, then it doesn't (for more, see my answer here). For the most part, the latter option tends to mean that the question is essentially a coding-based issue and SO is the logical destination. However, it is certainly possible that a given question is off-topic for both CV & SO. The next most logical destination for R questions is the r-help listserve. I recognize the frustration that goes with having a question and having difficulty getting the information you need, but the SE ecosystem has a certain specific design, purpose and limits; it cannot serve all types of questions that can be asked.

• I take this answer to be consistent with mine. Two thoughts spring to mind. First, the number of questions that we end up migrating is rather large for comfort. Is it only because people don't read the help about what is on-topic carefully enough? If questions about using statistical software (rather than writing it) too often fall between SO and CV, then there may be a case for new area(s) of SE, failing which there should be stronger redirection to other forums (such as r-help). – Nick Cox Sep 6 '13 at 7:41
• I also underline the point made in discussion in the thread that @gung cited: if choosing between two areas of SE is too confusing for some, choosing between three is unlikely to be less confusing. – Nick Cox Sep 6 '13 at 9:26
• -1 I (as you know) disagree strongly. The "about how R works / how to work with R" issue is more nuanced. R is software for doing statistical analysis, not just a programming language. Questions about doing or interpreting output from a particular statistical analysis in (insert your favourite stats software) would seem to be relevant & useful under a broad Cross Validated site. "How do I use R?" for non-statistics (or not substantively statistical) questions should remain off-topic. [and -1 only because on meta that indicates dissagrement - nothing wrong with your Answer] – Gavin Simpson Sep 17 '13 at 3:27

CV has a policy, which is explicit at https://stats.stackexchange.com/help/on-topic

If your question is about Programming, ask on Stack Overflow. If the language is statistically oriented (such as R, SAS, Stata, SPSS, etc.), then decide based on the nature of your question: if it needs statistical expertise to understand or answer, ask it here; if it's about an algorithm, routine data processing, or details of the language, then please refer to the collection of links to resources we maintain.

That's fairly described as rather negative about anything where the code rather than the statistics is the focus of concern. It's germane that many postings on CV are bounced towards SO for that reason. (Some come the other way, too.)

Your question, however, combines several related issues that are perhaps better kept distinct.

• You are making some broad statements about how far and how well R packages are documented. Many active members on CV would have views on that, but it is at best context, and not suitable for a debate on CV Meta. I just note in passing other views such as this from @joran (50K reputation on SO) in Why and when create a R package?

R documentation is absolutely not the place to learn stat methods. Even vignettes assume a certain level of sophistication. Too many complaints about minimal documentation in R really amount to complaining that the docs aren't spoon feeding them statistical knowledge.

• The policy of SO on different kinds of R questions is a matter for SO. The stated aim of SO is to support professional and enthusiastic programmers, and many questions on SO that are about someone else's code get little or no support (and indeed sometimes rather hostile or negative reactions).

• That leaves CV policy and the questions you raise but do not really address are Is our policy wrong? Why should we change? What should be our new rules if those questions are convincingly argued? In fact, our policy is to be positive about questions in which statistical analysis is the focus of concern, and we often encourage posters to bring that to the fore (or be migrated to SO otherwise).

I agree with you that many of the issues arising with R also affect use of other software too (SAS, Stata, etc.). In practice users of such software also have access to support from the vendors and there are healthy software-specific lists and forums that are broad-minded about software-specific questions. Then again R-help remains a very active list.

• Your first quote is specifically under the topic heading Programming. I.e. the way the advice is currently phrased, the entire quote only applies to question about programming. Using R to do statistical analysis is not programming, hence questions about that are not programming, would certainly be OT for Stack Overflow, and the clause would not apply. Now, if such questions aren't on topic here, fine, but the advice needs to be changed to reflect this. My personal opinion is that Q's of a statistical nature, including the use of software to implement an analysis, are suitable on CV. – Gavin Simpson Sep 16 '13 at 23:15

As a moderator I have to cope with this issue many times a day, so let me briefly share the principal considerations that are involved.

When it is at least possible to answer a question on stats, data analysis, or machine learning in a way that does not require knowledge of a particular computing platform or language, then it is potentially on topic here.

(Any answer to such a question that is comprehensible to a non-user of the target platform or language is therefore appropriate, even when it may include working code. If it only includes working code, without further explanation, we may appreciate the respondent's effort but we should also be inclined to migrate the entire thread to SO.)

Questions that are understandable by or of interest only to users of a particular computing package or platform are prima facie about that platform and belong on SO.

We have the flexibility to point out that certain questions originating from software problems have universal interest. We tend to employ that flexibility by encouraging posters to phrase their questions in general terms. "How do I do a factor analysis in R" is off topic, but "What is it about how I am doing this factor analysis that causes this particular problem" is potentially on topic, regardless of whether the computing is being done in R, Stata, or by hand.

Please note the important implications for would-be answerers: in order to communicate with everyone we speak the language of statistics here, not the narrower dialects known as SAS, R, Stata, SPSS, or whatever. Therefore answers should not be presented solely in one of these languages, either. We might look to the best publications in our field as a model: they all permit only a small number of natural languages and they employ a universal mathematical notation. Papers submitted in Welsh or even Chinese are not accepted in most of them--even though Chinese may be one of the most spoken languages on the planet now.

• Although I haven't done a study, I am reasonably certain that more questions on CV use R than any other language and that this is also true of answers. I often include mention of both R and SAS. But statistics, in any practical sense, requires some package. Yes, factor analysis can be done by hand - but it would take a lot of hands! – Peter Flom Sep 16 '13 at 21:36
• @Peter Presently 4527 questions have been tagged with R (and perhaps another thousand untagged threads may see R used in an answer). That means that approximately 80 percent of the 25,000+ questions do not have an R tag. The only lingua franca in statistics is (a small subset) of mathematical notation. We write our models using the language of Calculus and Linear algebra, not R or whatever, and if we want to talk to the rest of the world--including the majority of statisticians--we would not consider doing otherwise. – whuber Sep 16 '13 at 21:44
• Hi @whuber . I didn't mean to say that most posts here use R; I never thought they did, and your post has the numbers to show that they don't. However, while 4527 have the R tag, only 233 have the SAS tag. Further, many people use R code in their answers ... I'd say more than 1,000. While calculus and linear algebra are the lingua franca of statistics; R may be on the way to becoming the lingua franca of data analysis (I don't think I've used any calculus in any of my answers). – Peter Flom Sep 16 '13 at 21:49
• @Peter That's a reasonable anticipation. But it brings to mind the large library of books written in SAS over the last 30-40 years, no doubt by people who expected it to become the standard statistical language. I think it's a safe bet that within a few decades R will still not be the language of data analysis (it has too many flaws) and it's a pretty good bet some other language will have superseded it in popularity. Oh--Calculus is so familiar you don't even notice when you're using it. – whuber Sep 16 '13 at 21:57

I am not sure I agree with the previous answers. Something like “How can I run a factor analysis in R?” would seem like something both would see outside the scope of this site but I am not convinced it should be.

While the question does not require much statistical expertise (the relevant decisions have apparently already been made), I don't see where else it could be answered in the StackExchange network (of course, you could also try with a mailing list, ask a friend or hire a consultant but that's true for virtually any question on this site).

Turning to the letter of the policy, the question is not about “an algorithm, routine data processing, or details of the language” so it's not clear that it should be migrated to StackOverflow. In computer science terms, it could be understood as a question about R's “API” but such questions seem uncommon on SO, at least when it comes to R. In any case, statisticians, not programmers, are most likely to know the answer.

Both the policy and practical experience therefore suggest that questions about running some analysis in R don't fit on StackOverflow. Consequently, the only choice left is to refuse to help people seeking this type of information and simply close the question but what do we gain by doing that? They seem perfectly answerable (they are not unclear or subjective), probably require less effort than the more challenging statistical questions and are not so numerous that they would create insurmountable practical problems, even accounting for the fact that answering them could in turn result in more and more similar questions being asked.

If we decide to be a little more accommodating when it comes to software-related question, they could become part of a useful knowledge base for anybody seeking to perform data analysis, along with more theoretical questions, suggestions on how to tackle new or unusual difficulties, questions about good practice in common situations, practical advice to beginning data analysts, literature recommendations and all the other type of questions asked on this site.

• “How can I run a factor analysis in R?” qualifies for me as asking about the details of the language, i.e. which function(s) to use, in which libraries, etc. I can't see that as "clearly" untrue. So, I think this is excluded by present policy. You are arguing for a policy change as I see it, and this is the place for that. There being no place for this on SE is a weak argument, as @Gung has already discussed. Most questions of this kind would be poor questions for us if only on the grounds that they show little or no research effort, in terms of (not) trying to read the fine documentation. – Nick Cox Sep 9 '13 at 9:56
• A programming language includes a syntax (specified in a formal grammar), basic constructs (loops, branching instructions like “if”), a type system, etc. but a function written in a language (whether it is part of an API or package or not) is clearly not part of the language. While I don't necessarily want to give too much weight to the specific wording of the policy, I do therefore stand by my interpretation that it does not, as presently formulated, forbid this question. – Gala Sep 9 '13 at 10:04
• Also, to find the documentation, you need to know where to look, i.e. the name of the relevant package/function. I therefore don't think this question is trivial or shows an evident lack of research. Most importantly, all this would still not amount to a positive reason to close any question. Concretely, what's problem? – Gala Sep 9 '13 at 10:10
• PS: I was just editing my answer, I removed the “clearly” you alluded to for purely stylistic reasons (just clarifying if someone else is wondering). – Gala Sep 9 '13 at 10:12
• On what is the "language", there can be different views and yours is much more restrictive than mine. People asking how to do factor analysis in R are, on my wild guess, likely to regard any function included in whatever they download as part of the language. What's to stop someone saying the language underlying R is really C? But the fact that we are disagreeing suggests that the policy is not clear enough on what is excluded and what is not. – Nick Cox Sep 9 '13 at 10:21
• I don't use R routinely but a quick Google provides answers to that factor analysis question. The reasons for closing questions are all negative, so I am not clear what point you are making there. Would you allow questions on how to calculate a mean in Excel? – Nick Cox Sep 9 '13 at 10:32
• Would you allow questions on “how to compute a mean” without reference to any software? If no, would you then reject any question that does not make any reference to a specific software package? If yes, why is it somehow problematic if Excel is involved? – Gala Sep 9 '13 at 11:04
• I am just trying to focus on specific cases as trying to understand the policy statement is not working (for you). But to answer this: "how to compute a mean" is a poor question as showing no research effort. Actually, it is immensely more trivial than "how to compute a mean in Excel" as one could easily understand in principle how to calculate a mean, but still not know a software instruction. (If people don't know the former, CV is not the place for them.) The problem for me is opening the gate to a large number of lazy questions on software. Our present criterion is difficult enough.... – Nick Cox Sep 9 '13 at 11:11
• I am not sure what you mean by “negative reasons” (and apparently I wasn't clear when talking of “positive reasons”) but what I mean is that questions posted on the wrong site, questions that are not understandable, entirely opinion-based, too broad, too specialized or completely unrelated to the interest/expertise of contributors are likely to remain unanswered and just add clutter. That's a good reason to close them as opposed to doing nothing (and I think this list covers most reasons for closing questions). – Gala Sep 9 '13 at 11:14
• I don't see any similar practical obstacle to a handful of extra software-related questions. Are they likely to remain unanswered? Unlikely to be useful to future visitors? So numerous that no other statistical questions get asked and answered anymore? I speculate that there wouldn't be that many of them and the site/community can easily digest them (including by ignoring them if you find them personally boring) so that I don't see any reason to actively discourage anybody from asking them. – Gala Sep 9 '13 at 11:21
• OK; my speculation is quite different, but I will stop there. What's important clearly is the consensus view. – Nick Cox Sep 9 '13 at 11:31
• I upvoted the other good answers, but I sympathize with your idea too. These questions are very likely to attract new users to our community, as they provide quick solutions in a world we are always on a rush (I say this in a sense of having a broader scope place to ask, but not incentivizing questions with lack of effort). In fact, I think we are already having questions like that nowadays and not being closed. +1. – Andre Silva Sep 9 '13 at 12:45