62 comments

[ 6.2 ms ] story [ 124 ms ] thread
I'm a statistician that knows just enough about computer programming to be dangerous. It's hard to overstate how incredibly important R is to my discipline. No other language allows me to express my thoughts and prototype statistical ideas quickly and effortlessly.

If statistical programming was still stuck in the SAS era, I think there is a non-zero probability I would have lost interest in the profession years ago.

Glad you're still interested! I agree–R is light-years ahead of the competition (Python, essentially) in most statistical domains. It seems to fit the workflow better.
Light years ahead? It doesn't even support 64-bit integers. The R language cannot count past 2.1 billion. In 2018. Don't get me started on the package system.
I'm always hearing about these and other problems that programmers have with the R language. In practice, none of them seem to be a big deal to statisticians.

64 bit integers? Never had a need for this, but maybe there is a package that can add them in?

What's wrong with the package system? I maintain an R package on CRAN and I'm quite smitten with the package system.

I think bit64 gives integer64, but like you I never need large integers - I don't do general purpose programming in R.
What is the overflow behavior? If it fails and warns you that some operation overflowed, I don't see an issue.
It converts really large integers to floats, which can lose precision. You need to handle really large numbers as characters, or use bit64.

I only really started hitting this in the private sector though, never a problem when I was in academia.

Oh. That's kindof... gross. Better than wrapping silently I guess. Can you at least tell when a number has been 'promoted' to a float so you know you need a bigger type?
Also fairly critically; a mathematician can go from assuming that one exists as a concept to multiple ordinals of infinity with about 20 minutes of scribbling.

The fact that 64 bit is a modern standard doesn't exclude the fact that R cannot under any circumstance handle the vast and overwhelming majority of known numbers.

I feel sorry for the poor souls who turn out to need it, though. R sucks like that.

> I'm always hearing about these and other problems that > programmers have with the R language. In practice, none > of them seem to be a big deal to statisticians. > 64 bit integers? Never had a need for this

This kind of thinking is pervasive in a wide corner of statistics and this is pretty much why machine learning stole its crown, that's why I get to hear quips like "Statistics ? Is that even relevant ?"

Crown of what? They are complementary fields. Try doing ML without any statistics and lets see how far you get.
They are closer than complementary and that is exactly what I am trying to point out.

How much funding, support, mind share, conferences, venture capital yadda yadda does stats get compared to ML -- thats what I mean by losing its crown. All that ML has now could easily have been stat's were it not for the attitude I draw attention to.

Isnt that sad, given that ML in many cases is just stats without the baggage "R can solve all of my problems and whatever R cant solve isnt a stats problem"

Yes I agree wholeheartedly, sorry I originally missed your point. I do think it's more of a DL vs. the world problem than stats vs. ML but everything you said rings true. I was kind of odd in that I started with DL and then became fascinated with statistics and lost focus with DL. Statistics is just so much more useful outside of the niche domains where DL is extremely effective.
> Statistics is just so much more useful outside of the niche domains where DL is extremely effective.

This. Sorry had to.

32 bit integers or not, that's a bit tangential to R's dominance as a statistical language.

I work in population-level genomics and haven't found this to be a problem (yet?).

Furthermore, what's wrong with the package system? That's one of R's strengths.

I honestly find it far superior to python's 10 different solutions, none of which really work in a foolproof manner (and I use both languages daily).

That's not true. The bit64 package works just fine for 64 bit integers. Also, for most use cases in R's domain, it doesn't even matter.
A language is made popular by its ecosystem. R has not only the latest statistical tools implemented through packages but also domain-specific ones. I use both R and Python, but for data analysis, modeling, and plotting - R is much ahead of Python. Find an obscure or cutting edge method, and chances are someone has implemented it in R.

And the package system is absolutely smooth. I have never till today had any issue and I have used it on a weekly basis for the past 6 years.

Whats your issue with the package system? Genuinely curious
I think I once had a problem with R's package system that I couldn't resolve without pulling from a project repository. With python, it seems every other pip install I do causes some kind of error that regurgitates a metre of error messages and ends up asking me to compile a couple of packages myself, and whatnot.

R has a lot of antiquated, clunky syntax and libraries and mightily unhelpful package documentation, but one thing that isn't borked is the package system - and that's especially compared to python.

My heuristic is: if my program is going to be 80% NumPy and friends anyway then R is probably better but if it’s going to be only 20% (e.g lots of user interface code or whatever) then Python is better. I probably wouldn’t use R for anything end-user-facing unless it was via Shiny, whereas I might use WxPython for a desktop app.

For interactive, exploratory/research use R in RStudio beats Python in Jupyter hands down.

Had to learn R for a statistics course. It was honestly the worst programming language I've ever used and I've once wrote something in Malbolge.

The package system is absolutely horrid, a barely working mess if I ask it anymore complicated than "install package, any version is fine". Installing older packages because my distro lacked a compatible library for the newest was met with rather bizarre error messages. I think Latex has solved this much better. Even NPM solved this better. If NPM has solved package managing better than your solution it's time to rethink your life choices because that is a very low bar.

The object and type system seems to be made of wet tissue paper, I always feared that staring at the code too long might break it. It also doesn't help that every package has invented a completely new way to pass parameters, how to name parameters and functions and how it all sticks together. Also nevermind trying to read numbers larger than a signed 32bit number, R can't handle anything beyond 32bits for reasons that aren't entirely clear to me. Though last I tried it was very happy to just dynamically convert to a float32 instead which immediately makes it worse than Javascript because atleast Javascript's Number type is consistently a float and doesn't magically turn into the burnt remains of my hopes and dreams.

On top of all that horrid stuff sits R Studio. When first installed on my computer, R Studio was of the opinion that the best option was to install itself as default program for EVERY SINGLE FILETYPE completely ignorant on if it understands it. I'm still trying to cleanup my laptop from the mess it made. The IDE has varying opinions on how to write programs, usually none of the good ones. It also likes to sprinkle it's caches and configs and other files into every corner of my filesystem. Every folder is Free-For-All for this IDE. My home directory should not be used to re-enact scenes from Battle-Royal shooters, especially not by tools meant for developing software.

It's not light years ahead of the competition, it's not even competing. It's sitting on the sidelines trying not to fall over from the stress of being outside and exposed to the elements.

I'm happy I passed my statistics course because I will never ever touch this language again. Ever. I'm still cleaning up the pieces from using it for only half a year and I would rather port the Linux kernel to Brainfuck before using this language.

Sorry to unload all of that on you but I'm very frustrated with R.

Okay so Rstudio had a bug and R doesn't support realky big numbers that you will never need except with a add on package. Horrible.

Seriously though, R is lightyears ahead in things that actually matter.

There are hundreds of advanced statistical models that you can only run in R. Coded by the people who invented those models, most likely.

Python can do basic linear models via statsmodels, that's pretty much it. Not enough to cover even the baseline of common data processes or inferential tasks of a researcher or statistician.

So either R, commercial packages or you code everything yourself, which makes so sense for hundreds of reasona, among them that you have to study the R codes of the authors anyway.

So please, be real

> Rstudio had a bug

Multiple bugs even, some of which were rather popular on the bug tracker.

> R doesn't support realky big numbers that you will never need except with a add on package. Horrible.

I needed them, so I don't particularly care that you think it only matters in add on packages. I do recall my dad once claiming nobody should need more than 2GB of memory ever. That was around 2005 or so.

>There are hundreds of advanced statistical models that you can only run in R. Coded by the people who invented those models, most likely.

Which is the most concerning fact of them all.

> So please, be real

I'm real. This was a real application of R as a software and it sucked. How is this not real?

I mean I'm not saying you can't write anything in the language, you can certainly write code in it and make it work in a reasonable timeframe, atleast one advantage over Malbolge. But it doesn't change the fact that when I try to write something it feels wrong and painful and the software ecosystem seems to be written by non-engineers doing non-engineers leading to unmaintainable code everywhere with no standards whatsoever.

I would not consider R to be a language fit for anything but statistics and there only by virtue of, as you mention, having some packages that might be useful, which is a horrible reason to keep using a language.

But R... is a language for statistics. It's not a language for anything else. RStudio is pretty good now, I have never had issues with it. But you could, you know, use your extensive programming skills to use something else?

It's not that packages are useful. It's frankly that they are necessary. R is a complete statistical package that allows you do to your job or do research. It's the only statistical package that does this for free.

Given that there are no alternatives, it's hard to even see your point here. You wanna switch languages because you don't like R? Great, but now you can not do your job. What's the point?

In research, where R is used, you have to run a lot of models per project in a short amount of time. You could theoretically go back to the paper. Often, understanding the model on paper is quite different from understanding the implementation. So after some study, you dig up the code (in R), and programm the model into another language (where I think Python will be the only option bc. of NumPy). And then you have spent a couple of days doing basically nothing. Now you have wasted everyone's time, and you probably have bugs or don't implement a minor details correctly so that your results differ from R, so that you are giving wrong results or at least invite issues with replication...

Look, I don't like using R either. For my research, I use prefer to use Matlab as I anyway do have to program most of the things myself.

But when it comes to running quick stats analysis, I sure as hell fire up R, just like everyone else. I'd be a total idiot if I go and write up every standard and non-standard method in my language of choice. Also, I'd be fired.

No, R is not for you, since you care about 64bit numbers and typecasting elegance and like to write everything yourself.

But R is really popular with many other people, people who can fire it up, for free, do some rather advanced stats analyses without spending weeks of prep, and get their results out fast and in a reliable, replicatable manner.

My point is that R is horrible, even when used for statistics but it's the only solution in statistics so people use it (probably with some self-reinforcing stockholm syndrome)
Do you have any actual critiques that may apply to a day-to-day workflow of someone doing statistics?

Assume packages and RStudio work as advertised and he/she does not need 64bits.

> Assume packages and RStudio work as advertised and he/she does not need 64bits.

I.e., "Disregarding the weak points, what weak points are there?"

was this comment supposed to contribute anything? We've already went over those. Most reasonable people would probably not prefer to sit here and reiterate the same points multiple times.

edit: And as was explained - they hardly have an effect on most R workflows. I write R. I know people who write R (and Python) for production models. We could care less about 64 bit, and I for one think RStudio is rock-solid and one of the best IDEs I've ever used. And the tens of comments in this very thread about the package system show that no, it is not a foregone conclusion that packages are poorly handled.

You can call R functions from Python. You can then write a Python wrapper around R packages that you need.
> There are hundreds of advanced statistical models that you can only run in R. Coded by the people who invented those models, most likely.

Does this not seem worrying? If there's exactly one implementation in use by everyone, and nobody has read the original paper closely enough to build it independently & check?

Why do software engineers seem to care about things that likely matter very little in applications, while forgetting about stuff like if the thing is actually able to solve the problem you are trying to solve?

I mean thats a nice Ferrari u got there, but it still not going to cross that lake. My boat is a bit weird and rusty... But it is a boat.

Except I don't have a ferrari, I have a workshop where I can build a vehicle for any purpose with materials that are the most fitting in performance and price for the task, down from a simple wooden gokart to a Saturn V launcher stage.

And you have a rusty boat.

You have a workshop that could theoretically build a boat, but since crossing the lake is not your job, you don't do it.

You feel good about being able to build a boat. What you do not know is, that if you ever need to cross that lake, you don't have the time to build the boat. And you'd find that you need a special boat, so you have to go back to the rusty boat collection and reverse-engineer it anyway. And there are many other things to organize such that you don't even have the time or money to build your boat.

I only needed to cross the river once and I'm horrified that there is only a rusty boat and I will complain about that

I will refuse to cross the lake until necessary at which point I will evaluate if the safety of my life is worth more than the rusty boat, to which the answer is yes, so I build a new boat.

You almost got it.

There are people who need to cross the river. Every day, several times, at different positions that each require different types of boats. These people rely on these boats because although they are rusty and don't look nice, they always get the job done.

Since you do not need to cross the river, you are perfectly content with your Ferrari. Although you could upgrade it to a Ferrari-boat, you just don't need to. You could though. It would take a week, but you could. It'll probably be a great Ferrari-boat, if you did everything right.

But since you have no interest in crossing the river, you don't understand why people use boats. They are obviously slow and not shiny. And, most of all, they are slow on the road. You don't get it, why use boats? And so you say that boats are bad.

But boats are not bad. Boats work for crossing the lake, while your Ferrari does not work except with exceptional upgrades that cost money and time. And people who use boats do not go on the road. They don't need to. But they need to cross that lake, often, and they need their boats.

You can argue all you want, but as long as R is the best language and package for doing statistics, your critique is literally

"R is not good at something R was not designed to do. In theory, my language would be better than R, although it is not because in the real world my language doesn't have the necessary features".

It's not about the features, it's literally about library support. If someone wrote an easy to use R-emulator in C then all this would be moot since you could then just bind the libraries into literally every language ever.

I'm not proposing that "my language would be better", rather, "every language would be better".

But nobody has written it and most likely nobody will, because statisticians are perfect happy with R and programmers aren't using R enough to bother.
The R interpreter is written in C and there is an API allowing you to use it from other languages.
Same here; I've tripped over various of the misfeatures described in http://arrgh.tim-smith.us/, which I wish I'd had when I started.

(About the object system: which one? There are several of them.)

That's really interesting to hear. I am an engineer rather than a statistician so my usage is probably different (Mostly analyzing and modeling process data).

SAS is so entrenched in my organisation and there is such a long history of legacy SAS code that I feel like at this point it is probably impossible to migrate out of it.

How did you end up adopting it was it an organisation wide thing? I was able to get my work to send me on R course last year (Based around Microsoft R-open product).

I've found it pretty difficult to get other people here to switch the barrier is just a bit higher (functional language which people aren't all that comfortable writing etc) and lacks all the legacy code.

At our company adoption of open source tools happened bottom-up despite us having licenses for SAS, SPSS, Emblem etc etc. you name it we have it. But even having easy access to these tools people here still found downloading R/Python was easier still than logging a call with IT and having to manager approval to install software.

Oh and on the legacy code - no it never goes away. The handful of SAS programmers around 20 years from now will be able to charge fortunes to maintain those legacy systems.

Similar experience at my organisation, it definitely happened bottom-up. I hear that before I started, there was a locked room with a PC that had "that open source R" on it and people had to go to management and have some good reason if they wanted the key.

Few years later, everone is using R and python for everything they do ad-hoc; so it made sense to also let them use the same languages for bigger projects.

When we had to make some changes to legacy software for GDPR compliance, we took the opportunity and completely migrated some big legacy projects from SAS to R. We've just been able to get rid of licenses for some particularly costly SAS modules because of this.

R and Rstudio have been my primary bread and butter maker. You might argue that Rstudio has financial interest in growing R community but it's fair and it has helped overall R as a language entirely (not just as statistical one). Hadley Wickham's tidyverse is an amazing example of how one can simply get stuff done. Along with %>% pipe it is almost like idiomatic python. The ecosystem is amazing, I can write a web scraper in a couple of lines of code as simple as beautifulsoup. I think that's the strength of R. The intuitive UI and easy setup of RStudio just help someone get started with no hassle. That's a key I believe. I have also trained non-programmers and they managed to do data analysis in R using tidyverse in a matter of a month or two max.
R was the first language I learned (I ... do not recommend this) and while I don’t use it Day to Day at work, I’m always using it for fun side projects about everything from baseball statistics to urban planning. I’m not a professional statistician, by any means, but fully appreciate the work the community does with this toolset.
Thinking about the long run: Is there any version of the future where the best and largest library of statistical procedures could be somewhat language independent, and not organically part of a small language that itself is an unholy alliance of a matlab-like quick-and-dirty syntax and a hobbyist-level scheme interpreter runtime?
If you really want this to happen, you should probably start contributing to Julia.
There is an xkcd comic for this one on JavaScript Frameworks.
R was the first programming language I learned and I still use it a couple a times a week for work, but it wasn't until about 2 years into using R when I started learning python that I realised programming isn't difficult and frustrating, R is just badly designed.
In my opinion, R is the best language for quickly exploring, iterating models, validating the models, and repeating the cycle. I would be curious to hear whether Python, which I use for preprocessing the data into flat tables, is as good as R in this domain.

Also ggplot2 and tidyverse packages are powerful for accelerating your iterative cycles.

Absolutely not! If you're given a dataset and you're trying to fit a model or even run exploratory analysis, Python doesn't even come close to R. Even with Jupyter, the experience is not as smooth as R+Rstudio.
Except if you like Vim keystrokes. The R Studio implementation (as I understand it's just the ACE library) is really crap.

I find even the Juptyer-notebook Vim plugin is better than the R Studio implementation :(

I use Rstudio with its vim implementation. I would be curious to know what are the things that are missing compared to vim?
There's a bunch: https://support.rstudio.com/hc/en-us/community/posts/2008793...

The most annoying one for me is the way x behaves. Go to the end of a line. Press x (delete character). It's supposed to delete the character, then move the cursor to the left, so you can delete the next character. It just stands there. That's wrong (try Vim or Visual Studio with vim keybindings). It just annoys me a lot because that's how I've always gone about deleting chars instead of using backspace or using ctrl-h.

I've tried both R and Python for data analysis and data wrangling and the experience with R was a whole lot better for me (I work as a business intelligence consultant). Python is really steeped in programmer culture, which you notice in everything from its user base to its manuals. Which is great for people who want to learn programming or study CS or so.

But I'm not a programmer and I don't want to be. My biggest program ever written is maybe 150 lines to covert a mess of excel files to something usable. Programming is a necessary means to an end for me to do my job, but every time I tried to learn actual programming it bored me to tears. R, while I fully admit has a syntax which is clunky at best (although the tidyverse really helps here), does exactly what I need. Its users are all active in roughly the same space (data analysis in all its forms) so finding help is easy. The community is incredibly friendly, easily found on Twitter with the #rstats tag. It has packages for everything I would ever need. Basically, R helps me get things done, which is all it needs to do for me.

I think your post illustrates well why both languages are important to have. I also work in the Business Intelligence - space, but my job is usually more focussed on setting up data pipelines and developing a small specialized web app here and there. So if I'm already doing that, and I do analysis on top of that, of course I'm going to pick Python, because I can stay in the same ecosystem and I already have a better feeling for how things are going to work. But this wouldn't make sense at all for someone who generally works more on strategy and decision making and wants to dig a little deeper from time to time.

Although when people ask me for a recommendation on what to learn, and they're actually interested in programming and building things themselves, I always recommend them to at least give Python a shot and see if they like it, as it then also gives them the possibility to do a lot of other things with the language.

It's really interesting that there are such divergent opinions on R and Python. I'm curious why some people seem to find R incredibly frustrating and Python entirely sensible, and others find R miraculous and smooth and Python inaccessible.

Is there some set of improvements to Python that would make it popular with R users, or vice versa? Or is it a fundamental difference in taste that will never be bridged?

I think one reason people may not readily like R, is because it is a functional language. Most programmers are comfortable with object oriented programming rather than the functional style. It takes a while to get used to it.

I have seen people who started programming with R, and they get fluent in it pretty fast.

I've been programming for a long time and had to learn R a few years back for a series of projects. The documentation and community seemed to me, as a newcomer, to be very focused on how to solve particular statistical and modeling problems, and I was almost always able to do what needed to be done relatively quickly. (Python documentation and communities, in contrast, span all kinds of applications that can be difficult even for an experienced programmer learning Python to sort through and evaluate. I can also imagine the migration to 3.x has been a challenge for newcomers.)

Although I enjoyed learning and using R, as a CS person I was bothered that I understood how to do X in R, but I had no clue about what was happening when I did X. I found this paper to be particularly useful in describing R from a CS perspective: http://www.lirmm.fr/~ducour/Doc-objets/ECOOP2012/ECOOP/ecoop...