11 ms·
HN is predisposed to hate R because everyone here is coming from a "real" programming context. Their concerns are generally valid, but they should keep in mind
by extr 8y ago
HN is predisposed to hate R because everyone here is coming from a "real" programming context. Their concerns are generally valid, but they should keep in mind a lot of people using do not have a software development background and do not care that the language is not elegantly designed: they just want to get analytical work done. In that respect, R is far, far superior to Python. Even something as simple as installing a library is a conceptual leap for these people (why wouldn't the software just come with everything needed to work?). Have you ever tried explaining the various python package and environment management options to someone with a background in Excel/SQL? Just getting a basic environment set up can be days of frustrating effort (though Anaconda is getting better with this). Compared to R, where you install RStudio and are off to the races, with a helpful package installation GUI. Another great example: in R, data types are pretty fungible, everything is a vector, coercing things generally "just works". In pandas, it can be very confusing that you need to explicitly turn a 1x1 dataframe into a scalar value. Same thing with Python vs R datetimes.
I understand some of this stuff is actually seen as a positive for Python in some contexts (production usage) and I agree. Just pointing out the woke take is the languages are both good, but good at different things. If I need to run a quick analysis on a dataset, I'm grabbing R 9/10 times. If I'm building a production pipeline, I'm using Python 9/10 times. This is perfectly fine.
- acomjean 8y agoAs a datapoint in agreement. Some of the Biologists I work with love R. I had one tell me that its like how they think, and they weren't a python fan. I think R-Studio (an R based IDE that turns it kinda into a more excel like experience) where you can inspect the data in memory (including matrix data) and graph making is where it really helps bring people into the R language. And with a set of instructions anyone can go load the analysis packages and do their data analysis. Compare this to python, where they have to go the unix shell set up the environment, load the libraries. When they come back reset everything and get back to where they started.
- ekianjo 8y agoYou can also use R in Jupyterlab these days and while its quite different from RStudio it is quite practical to conduct data exploration.
- angry_octet 8y agoAnaconda and Jupyter is a much more friendly environment than straight writing .py files, much like r studio. It lacks the integrated debugging features, though vscode does provide some rudimentary assistance. I'd say it's superior overall, especially in regard to getting help and documentation.
- newen 8y agoYes a couple of years ago I did this project where I needed to get a ton of analysis done, typically with plots and tables as output. Did this in python and it was this huge mess with pandas and matplotlib. Re-did it in R with data.table and ggplot2 and it was just ridiculously easier, and I could expand upon the code much more easily, plus the output was much prettier.
- bokstavkjeks 8y agoIt's also worth noting that R becomes much more pleasurable with the Tidyverse libraries. The pipe alone makes everything more readable. I'm also coming from more of an office setting where everything is in Excel. I've used R to reorganize and tidy up Excel files a lot. Ggplot2 (part of the Tidyverse) is also fantastic for plotting, the grammar of graphics makes it really easy to make nice and slightly complex graphs. Compared to my Matplotlib experiences, it's night and day. Though I'd expect my experience with programming to be quite different from others' though, mainly because any code I write is basically an intermediary step before the output goes back in Excel. That said, if anyone's interested in learning R from a beginner's level, I can recommend the book R for Data Science. It's available freely at http://r4ds.had.co.nz/ http://r4ds.had.co.nz/ and the author also wrote ggplot2, RStudio, and several of the other Tidyverse libraries. EDIT: I'm also currently writing my master's thesis in RMarkdown with the Thesisdown package. It's wonderful, it allows for using Latex without really knowing Latex which is great for us in business school.
- riskneutral 8y agoTidy features (like pipes) are detrimental to performance. The best things R has going for it are data.table, ggplot, stringr, RMarkdown, RStudio, and the massive, unmatched breadth and depth of special-purpose statistics libraries. Combined, this is a formidable and highly performant toolset for data analytics workflows, and I can say with some certainty that even though “base Python” might look prettier than “base R,” the combination of Python and NumPy is not necessarily more powerful or even a more elegant syntax. The data.table syntax is quite convenient and powerful, even if it does not produce the same “warm fuzzy” feeling that pipes might. NumPy syntax is just as clunky as anything in R, if not worse, largely because NumPy was not part of the base Python design (as opposed to languages like R and MATLAB that were designed for data frames and matrices). What is probably not a good idea (which the article unfortunately does) is to introduce people to R by talking about data.frame without mentioning data.table. Just as an example, the article mentions read.table, which is a very old R function which will be very slow on large files. The right answer is to use fread and data.table, and if you are new to R then get the hangs of these early on so that you don’t waste a lot of time using older, essentially obsolete parts of the language.
- Avshalom 8y ago>>Have you ever tried explaining the various python package and environment management options to someone with a background in Excel/SQL? Yes, well, from the outside it doesn't seem like Python programmers have any better grasp of those either.
- vertere 8y agoYou might be right. Whereas programmers tend to regard languages as something to be understood, package managers are something they just use ("if it works, it works"). Typical R users (i.e. data analysts) regard languages a bit like programmers regard package managers.
- gbrown 8y agoAnother feature for this audience is the philosophy that functions shouldn't have side effects. You can still do (several types) of object oriented programming in R, but it does take away some of the ways in which non-programmers shoot themselves in the foot. I've come to really like the way environments work in R, as well.
- mr_toad 8y agoA sane language shouldn’t need three different object systems.
- gbrown 8y agoMeh, S3 is nice and lightweight for a very particular kind of analysis interoperability. S4 isn't super useful IMHO. RC is very well thought out, and I've heard good things about R6. It might not be sane language design, but it works well for designing very different kinds of analytical procedures.
- joker3 8y agoThe thing to keep in mind is that, from the point of view of someone who works with data, R isn't a programming language. It's a statistical software package that has a programming language. Its competitors are things like Minitab, SPSS, Stata, and JMP, all of which used to be entirely menu-driven. R was a genuine innovation when it was first introduced. Now it's certainly showing its age and the limits of its design, but it's still best in class for a certain kind of user. We could do better for software development, but it's not clear that doing so would actually make data analysis easier.
- deleted 8y ago[deleted]
- Giroflex 8y ago> Even something as simple as installing a library is a conceptual leap for these people (why wouldn't the software just come with everything needed to work?). > Have you ever tried explaining the various python package and environment management options to someone with a background in Excel/SQL? I don't understand the difficulty I've often seen voiced against this. Why would a newbie or someone who just wants to get analytical work done need anything beyond installing Python and doing `pip install library`? It's certainly orders of magnitude easier and faster than, say, using a C library. The only trouble I can see a newbie running into is if they want to install a library which doesn't have precompiled wheels and they need some dependencies to build it, but that's rarely an issue for popular packages.
- CJefferson 8y agoWell pip install library needs root, which you probably don't have. So now you have to teach them about making, and acitvating, virtual environments. Also, they can't easily search through the packages in a nice GUI and just click on the one they want to install.
- ekianjo 8y agoAnd pip s upgrade process for packages is almost non existent, while R supports that very, very easily.
- Thriptic 8y agoI actually totally agree with this. I learned how to program in R and found it to be quite wonderful to use as a noob. As you say, shit just works. If you think you should be able to do an operation, you typically can. To this day I still prefer cleaning and doing proof of concept analyses in R rather than Python. It's so much easier than having to fuck with pandas and numpy.
- yodsanklai 8y ago> Their concerns are generally valid, but they should keep in mind a lot of people using do not have a software development background and do not care that the language is not elegantly designed To me, the opposite is true. People with no CS background would benefit the most from a simple design. > in R, data types are pretty fungible, everything is a vector, coercing things generally "just works". Things just work until they don't, and then you need to understand all the weirdness of R. I don't know what's the typical experience of a non-programmer with R, but as a programmer, I had some headache trying to understand R semantics (apparently I'm not the only one [1]). [1] http://r.cs.purdue.edu/pub/ecoop12.pdf http://r.cs.purdue.edu/pub/ecoop12.pdf
- extr 8y agoI have a lot of experience teaching non-programmers R. Most of them come from an Excel/SQL background. I have found the amount of weirdness that presents a real problem is very low. And when it does get weird, I usually advise we just brush it under the rug and use a different method to accomplish the same thing. This probably sounds horrifying, but it's really not. Most of the code people write in R is not like other programming languages, it's rarely bound for anything other than the end user's laptop, if its even saved in the first place.
- crispyambulance 8y agoI use R at least a couple times a week. It gets the job done and I will be forever grateful for the tidyverse. That said, R can be goddamn frustrating at times because of the way the documentation is written. It would be nice to simply be able to query about a function and get a cogent help file that explains THE BASICS of how to use the function for the most common use-case(s). Instead, the help files try to be "canonical" and front-load a bunch useless technical detail-- like that something is an "S3" object. Still haven't figured out what that really means and, I expect, that knowing something is "S3" will NEVER help me out when I am in a jam and need a little help to do something simple because I forgot some data manipulation detail. Instead, I end up googling all the time connecting the dots all over the internet to get very simple stuffs done. At least now we have stackoverflow which, as vicious as it is, seems like Mister Rogers' Neighborhood compared to the old R mailing list.
- ekianjo 8y agoThe documentation varies a lot by the package. Some libraries have excellent help files, while others are poorly written. At best, its inconsistent.
- killjoywashere 8y ago> though Anaconda is getting better with this Anaconda is becoming to python what Chrome is to browsers, particularly as Jupyter matures. Drop it in, and a huge amount of what you want to do is ready to go. Sure, there's lots of libraries/extensions available, but most of the time you can do real work with a default userland, non-privileged install.
- ekianjo 8y agoAnd there is litterally no equivalent to dplyr and ggplot2 in Python. Those alone can make a huge difference in how many lines you need to write to do something.
- asteriske 8y agoggplot2 has plotnine (http://plotnine.readthedocs.io http://plotnine.readthedocs.io) which has a nearly identical API. I've found though it's not perfect, you can get closer to dplyr with JS-style method chaining on Pandas.
- ekianjo 8y agoI tried plotnine before and its far from covering everything ggplot can do. And chaining on pandas can make things unreadable compared to dplyr.
- tincholio 8y agoI've recently used plotnine, and it's been a relatively good experience, but Pandas is absolute garbage compared to the tidyverse, API-wise.
- durbatuluk 8y agoAs someone who taught R for students coming from Biology. Most of them just want to learn some_stat_test(), how to interpret it and who to plot(). These who tried to do modeling using vanilla R just dropped midway because of R performance and switched back to fortran ggplot2 just should be baseline instead of default gfx.
- maxander 8y agoNo, you are wrong. R is terrible, and especially so for non-professional programmers, and it is an absolute disaster for the applications where it routinely gets used, namely statistics for scientific applications. The reason is its strong tendency to fail silently (and, with RStudio, to frequently keep going even when it does fail.) As a result, people get garbage results without realizing, and if they're unlucky, these results are similar enough to real results that they get put somewhere important. Source: I'm a CS grad working with biologists; I've corrected errors in the R code of PhD'd statisticians, in "serious" contexts. Scientific applications require things to fail hard and often, to aggressively fail whenever anything is potentially behaving incorrectly. R does the exact opposite of that in several different, pernicious ways. IMHO, Python is more dangerous than a scientific computing language should be, but at least it will stop when it hits an error. R has undoubtedly cost humanity millions of dollars in wasted research costs and caused untold confusion, from otherwise perfectly-performed studies reporting corrupted statistical results. The world would be a noticeably better place without it. I simply cannot articulate my opinion about R without sounding grossly hyperbolic. I'm sad that HN, a place which is typically enlightened in the ways of the programming arts, is so confused what this article is on about. If we tolerate such blatantly hostile design in something as important as the language of scientific statistics, where do we expect to get?
- rpier001 8y agoHave you ever worked with other major statistical packages? Have you ever caught people doing data munging in Excel? R fails far less silently than the credible alternatives. Source: I've been around the academic block and seen many types of horrors. It's unfortunate that you've gotten to a _terrible_ feeling about R without realizing that many of the 'silent' failures are easily configured away (some examples, https://github.com/hadley/strict https://github.com/hadley/strict). That R isn't noisy about things that CS majors might think it should be by default is, BTW, entirely appropriate. Many of what one might call 'silent' failure modes in R are for the express purposes of making exploratory data analysis easier... and that was one of the original purposes for R.
- extr 8y agoThat's too bad, I wish R could be better and easier for these people, but I don't think it warrants your hyperbole. I can point to many of my own anecdotes where R has saved millions of dollars by empowering analysts to conduct data exploration and modeling that would have been vastly more complex undertakings using any other tool. They seem to handle the silent failures just fine (usually by double checking their results before presenting them). Poor rigor and coding practices in academia are practically a meme at this point. You really want to lay all of that at the feet of R? Suggest a code review step for their publishing process or use a different tool. R is certainly not perfect but the idea that "The world would be a noticeably better place without it" is silly.
- educationdata 8y agoOne common thing across most the "real" programming languages makes them unfit for data work: 0-based indexing. It is just ridiculous to call the first row in a data set as 0th row, and the last row as (n-1)th row. It does not make any sense for data analytic work.
- bograt 8y agoI'm not sure I understand this, and I'm genuinely interested in why it would be. I find zero indexing logical: zero is the first natural number and is thus a fine candidate for being the first ordinal. In my experience most mathematical series lose nothing in terms of elegance or readability by being indexed from zero instead of using more traditional indexing from one.
- goatlover 8y agoYou find zero indexing logical most likely because you learned programming on languages which are zero-based. But most of the rest of the population, including statisticians, for which R is the intended audience, likely start at one and aren't used to OB1 errors.
- newen 8y agoIt seems needlessly confusing to me to refer to the first number in a series as the 0th number. 0-based indexing is only good for offset counting, which is very much based on having a mental model based on pointer arithmetic for a number sequence.
- samatman 8y agoWhich years are in the decade the Twenties?
- newen 8y agoYeah years start at 0. But that's because it measures the offset from the beginning of the calendar. You can similarly expand this to all distance based measurements. But that is completely different from counting, which shouldn't be conflated with distances. People always say the first of some sequence and only people who care about 0-based indexing tries to spread the 0th of some sequence meme.
- jghn 8y agoI came from a "real" programming background. This was pre-Tidyverse. Learning R thoroughly was the best thing I could have ever done for my proglang understanding as all the weird things R had meant that every time I learned something new I could say "Oh, it's like X in R".
- yread 8y ago> install RStudio and are off to the races, with a helpful package installation GUI. Unless the package needs a native component like libcurl of particular version then it can turn into couple of hours of blindly trying everything you can think of. > Another great example: in R, data types are pretty fungible, everything is a vector, Unless it's a dataframe or factor or string or s3, s4 or s5 or a couple of other things. And the documentation will tell you the reference paper that you can read and some completely impractical example. Ugh, feels better now, sorry for the rant.
- itronitron 8y agoI am always amazed when I hear that people use Python in any type of production pipeline.
- leibnitz27 8y ago^^ THIS. And yet certain organisations I know have upwards of 40M lines of it. Run. Run. Run FASTER.
- terragon 8y agoCould you please elaborate on that? My company has tons of python code producing reports with reportlab, making UIs with PyQt5, as well as a multitude of small scripts to interact with MySQL. We’ve been nothing but happy with Python in the years of using it.
- YeGoblynQueenne 8y ago"I 've done it so it's not so bad" is not a very good argument. I've done a significant data science project in Prolog (with R for the plotting btw) but that doesn't mean Prolog is the go-to language for data science :)
- shakna 8y agoBut it is a datapoint against the hypothesis "Prolog is inappropriate for data science".
- YeGoblynQueenne 8y agoOh, true that :) Sorry, I might have misread your comment!
- itronitron 8y agoMainly because production pipelines care a great deal about performance (speed) and Python is generally considered to have worse performance in comparison to compiled languages (Java or C++.) Depending on your pipeline that may not be a big deal.
- Animats 8y agoHN is predisposed to hate R because everyone here is coming from a "real" programming context. There is that. Matlab has the same problem. One problem with "real programming languages" is that programmers who grew up with C don't see any need for built-in multidimensional arrays. This is one reason FORTRAN is still around, and why array work is straightforward in Matlab and R.
- int_19h 8y agoIt seems to be partly because they're rarely used in general purpose code even when they are there. Just look at C#.
- niceperson 8y agoThis is really stupid. Language decisions coming from a background native to them are always superior. This isn't a matter of "all opinions are equal". They never are. R is horrendous, plain and simple.
- shawnz 8y ago> Their concerns are generally valid, but they should keep in mind a lot of people using do not have a software development background and do not care that the language is not elegantly designed: they just want to get analytical work done. This implies we strive for good design in languages just because it appeases some ideal we have about how languages should be. But really we strive for good design in languages because it makes them more powerful, more expressive, easier to use, etc. Sure, maybe Python doesn't have all the right abstractions to be perfectly suited to statistical tasks, whereas R has more natural abstractions for that kind of stuff. But that doesn't mean that R doesn't also have many objectively bad design decisions even for statistical uses.
- randomsearch 8y agoGood point about the package management, but I disagree with your argument. Non-Computer Scientists seem to have a much easier time with Python than R, anecdotally. I think the reason is that R is not just a badly designed language, but in particular its design is inconsistent. That’s as confusing to newcomers as it is to people who care about PL design. I used R for almost a decade. Last year I switched to Python and Jupyter, never looked back. Can’t recommend the switch highly enough. R has great stats packages, but struggling with the language is just not worth it.
- deleted 8y ago[deleted]