20 ms·
A newcomer’s (angry) guide to R
- huac 8y agoI think many of the gotchas and annoying parts of base R are solved by using tools from the tidyverse: http://github.com/tidyverse http://github.com/tidyverse. For example, the pain of needing to specify `stringsAsFactors=FALSE` is solved in the tibble package by setting a sensible default. At any rate, at least it's not Pandas and matplotlib...
- bunderbunder 8y ago> At any rate, at least it's not Pandas and matplotlib... There's a certain yin and yang to the space, isn't there? You get to choose between a hacky language that has pretty good tooling built on top of it, or a pretty good language with hacky tooling built on top of it. I think that Python is probably winning because being a decent language gives you a decent escape hatch, whereas no amount of great libraries can save you from having to go through the bizarro language. That said, R may be bizarro, but at least, once you learn it, it's predictable. Whereas I'm not sure even Pandas really knows whether a given call to .loc will copy or refer to the original data.
- natalyarostova 8y agoPandas has a lot of defensive copying. I love Pandas, but I think it demands a lot from the user. When I started using it I was new to traditional coding (i.e. knowing anything about datastructures), and have come from R. Over time as I've learned a real amount about legitimate data structures, I've become far far better with Pandas.
- curiousgal 8y agoWhat data structures do you recommend learning about?
- natalyarostova 8y agoI literally did not understand the fundamentals when I started Python (e.g. Dictionaries, triples)
- kgwgk 8y agoThat particular issue can also be solved by setting options(stringsAsFactors = FALSE). Anyway, the default behaviour was the sensible thing to do at the time: https://simplystatistics.org/2015/07/24/stringsasfactors-an-unauthorized-biography/ https://simplystatistics.org/2015/07/24/stringsasfactors-an-...
- flother 8y agoBeware of adding that to your .RProfile though. The author makes a good argument for why that's a bad idea: your code will execute differently on someone else's machine. http://arrgh.tim-smith.us/factors.html#fn:options http://arrgh.tim-smith.us/factors.html#fn:options
- kgwgk 8y agoThat’s true. It may create more problems than it solves. I don’t change the default value myself, setting stringsAsFactors=FALSE when required is good enough for me.
- _Wintermute 8y agoI can't stand the non-standard evaluation of the tidyverse. It works great for writing one-off scripts, but as soon as you start trying to put it into functions or your own package it's just not worth the pain of quosures and the tidyeval nonsense that changes every 6 months.
- claytonjy 8y agoI used to feel similarly, but I think it's much more stable than it was even a year ago; `!!`, `enquo`, and `:=` is good enough for the vast majority of users who want to write their own NSE functions now.
- vertere 8y agoI hate it as well. And then you get people going on about "functional style" while throwing referential transparency out the window.
- cwyers 8y ago> There are subtle differences and some authorities prefer <- for assignment but I’m increasingly convinced that they are wrong; = is always safer. R doesn’t allow expressions of the form if (a = testSomething()) but does allow if (a <- testSomething()). ...I am confused here. If you're testing for equality, R requires you to use == and not =. If you try to test for equality with =, it throws an error instead of treating it as an assignment. That's good. But who is trying to test for equality with <-?
- zaphar 8y agoHe's not testing for equality. He's assigning to a variable.
- cwyers 8y agoHe's saying to use = instead of <- because it won't let you assign to a variable there. But that's because it assumes you mistyped the equality operator. The only reason you need safety there is because it's easy to forget that == is the equality operator, not =. It's not easy to confuse == and <-.
- Wolog 8y agoThe danger is that you can intend to type if(b < -9) and instead type if(b <- 9) The latter always evaluates to true and assigns the value you're trying to compare with to your variable. This can be extremely difficult to catch and detect, especially for people who aren't software developers. They aren't writing unit tests.
- bo1024 8y agoI had the same confusion, can only assume the author is worried about this typo: if(a < -b) (which I assume is a less-than comparison, though I don't know R).
- joker3 8y agoIt is.
- hendiatris 8y ago>A R factor is a sequence type much like a character atomic vector except that the values of the factor are constrained to a set of string values, called “levels”. For example, if you have a table of measurements of some widgets and each row corresponds to a single measurement of a single widget, you could have a factor-typed column called measurement.type containing the values “length”, “width”, “height”, “weight”, and “hue”, with the corresponding numeric measurements stored in a “value” column. This is a very bad example of what factors are for in R, because it makes it seem like factors are for defining variables or keys in key value pairs. You can use them for that, but it isn't the intended use. A better example would be: suppose you were comparing the amount of sugar in fruits based on several growing locations, and you had three columns: | Fruit | Location | Density (g/L) | Fruit would be a factor variable (let's say it takes the possibilities of apple, banana, orange), and location could be too, if it were a discrete set of possibilities (as opposed to lat/lon coords) This author seems to forget that R was built for working with data in an analytical setting, unlike all of the languages he's comparing it to. It has creeped into other areas, but that seems to be because in the hands of a skilled user it is far easier to implement a data analysis solution. I'm sure someone will come in and say how much better pandas is, but on the small datasets, I'll stick with R, especially with how brittle and buggy matplotlib is.
- minimaxir 8y ago> This is a very bad example of what factors are for in R, because it makes it seem like factors are for defining variables or keys in key value pairs That is the approach for tidy data, which is used a lot in the R tidyverse (http://tidyr.tidyverse.org/articles/tidy-data.html http://tidyr.tidyverse.org/articles/tidy-data.html)
- ejstronge 8y ago>> This is a very bad example of what factors are for in R, because it makes it seem like factors are for defining variables or keys in key value pairs > That is the approach for tidy data, which is used a lot in the R tidyverse (http://tidyr.tidyverse.org/articles/tidy-data.html http://tidyr.tidyverse.org/articles/tidy-data.html) Do you have a reference to where Hadley et al. suggest using factors in a key-value system? I'm reading Wickham's books at the moment and have not seen this assertion. Indeed, I believe he would not state this, as he explains the utility of factors explicitly: A factor is a vector that can contain only predefined values, and is used to store categorical data... Factors are useful when you know the possible values a variable may take, even if you don’t see all values in a given dataset... Advanced R, pp. 21-22
- fermienrico 8y agoHaving used Python, JSL, Julia, R and Matlab; I agree with most of the things in R. R is an extremely ugly language. It seems to be created by people who wear capris and uggs (both at the same time). But, R has incredible packages, especially the work done by Hadley Wickam. ggplot2 is beautiful. It is utterly gorgeous. It is what Ted Baker is to the capri guys that designed the language itself.
- geoalchimista 8y agoMy personal hack to deal with the unbearable ugliness of R is to use Rpy2 and call R packages from Python --- at least writing some boilerplate code in Python makes me happier than having to write in R.
- fermienrico 8y agoThis is game changing. Thanks, I can't wait to try this out.
- glup 8y agoSecond this. Pandas / Numpy / Numba until I hand off to ggplot, lmer, or whatever specialized R package.
- andrewla 8y agoggplot2 produces beautiful graphs. I don't think it's beautiful as a package -- the syntax is strange and reflects an earlier evolution of the ideas that went into the tidyverse. Notably the use of + instead of chaining operators, the use of a custom "ggproto" object system instead of S3 (which makes extensibility a nightmare), and the superfluous presence of the aes() function (rendered unnecessary by better lazy evaluation tricks not really well-explored at the time).
- digitalzombie 8y ago> the syntax is strange and reflects an earlier evolution of the ideas that went into the tidyverse. Because it's the "grammar of graphic" see the link below. https://ramnathv.github.io/pycon2014-r/visualize/ggplot2.html https://ramnathv.github.io/pycon2014-r/visualize/ggplot2.htm... If you don't like that syntax use another library. But ggplot2 how you code graphic like that is amazing for me and many other people. I've tried SAS and Matlab and ggplot2 is the best.
- andrewla 8y agoAs a long-time R user, I agree with all of these complaints. The language itself is ugly and actively tries to get in your way. I'll add that concepts like data frames are not really intrinsic, and you get needless complexities like "length", "nrow", "dim", each of which does the wrong thing in 90% of the scenarios of interest. The confusion of lvalues is another strange quirk -- a <- 0; length(a) <- 20 is totally valid, and you get things like class(a) <- 'foo' being preferred over the equivalent a$class <- foo. It has all sorts of odd concepts between lists and data.frames -- the double-bracket syntax, etc. The object model is very confusing, though most people seem to have converged on the S3 system, which is the oldest one. If you discipline yourself to learning "the good parts", especially by learning either data.tables or tidyverse or becoming a master of split/lapply/aggregate/ave, then it is very powerful. The modelling tools and plotting (both base graphics and ggplot2) are excellent. I'd love to see a NeoR arise at some point that fixes the strange historical inconsistencies (like what happens when you refer to vec[0], as noted by the author) in non-backward compatible ways.
- ryanmonroe 8y agoWhat is needlessly complex about length, nrow, and dim and why would they ever give you the wrong thing? length always gives the length of an object, i.e. the number of elements in it[1]. nrow will always give the number of rows, and dim will always give the dimensions e.g. for a data.frame with 3 rows and 4 columns dim(df) is (3, 4). [1]That is, top-level elements. If a list L contains 3 vectors, each with 9 elements, length(L) is 3, not 9 or 9*3 = 27
- curiousgal 8y ago>split/lapply/aggregate/ave I always feel bad when I resort to a for loop in R. Do you have any recommended ressources about mastering those specific manipulations?
- ekianjo 8y agoUnless you do something quitec complex dplyr is faster for such operations and consumes less RAM too.
- 8y ago
- JVerstry 8y agoI learned R coming from Java, Node, PHP and Python and I love it !!! It is awful as an application development programming language, but it was never designed for that purpose. It was designed for STATISTICS. Try to achieve advanced statistics with your traditional software engineer's preferred language and see which language you hate then. The only tricky R concepts to learn for newbies are: recycling, formulas and vectorized functions. Add RevoScaleR to R and it kicks major ass when dealing with big data manipulation. Oh yes, big time !!!
- curiousgal 8y agoAny recommended ressources for Learning those concepts?
- sdabdoub 8y agoHadley Wickham's R for Data Science[1] is a generally good starting reference. [1] http://r4ds.had.co.nz/ http://r4ds.had.co.nz/
- AlexCoventry 8y agoI'll take python over R any time.
- extr 8y agoHN 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.
- notafraudster 8y agoThere are a bunch of odd non-standard syntax choices in this tutorial. For example, the author ends statements with semicolons. R does allow equal sign assignment (although style guides prefer the stupid arrow syntax). The author mentions Bioconductorm the... second biggest package repository for the language? I clicked because I was a programmer for 15 years before I used R, and I have subsequently developed and shipped R packages, so I feel like I'm in a pretty good position to get the visceral, cathartic, "argh" the writer here was going for.
- rossdavidh 8y agothe "stupid arrow syntax" is not nearly so stupid, and I speak here as a 10+ year Python developer, as the misuse of the equal sign that every C-style language seems to think is ok. The = sign meant something long before computer programming, and it is something the developer community ought to be ashamed of that it is being used for "change this thing to that". /rant
- peatmoss 8y agoR was originally not much more than a bunch of Scheme macros if I understand the history right. Suspect <- may have just been an infix macro for define at one point. Of course I probably would have preferred just keeping the lispy syntax of scheme without all the infix stuff!
- YeGoblynQueenne 8y agoWell, the "=" operator is eas to type since it's on pretty much every keyboard and probably has been for ever. And it's faster than typing a two-symbol operator like := or <- so. If you want "=" to (more or less) mean what it used to mean "long before computer programming", try Prolog. ?- a = a. true. ?- a = b. false. ?- A = a. A = a. ?- A = a, A = b. false. ?- A = a, A = B. A = B, B = a. ?- A == B. false. ?- A = B, A == B. A = B. Nice? Most programmers would pull their hair from the root at all this :) (hint: "=" is not assignment, neither is it equality and "==" is just a stricter version thereof).
- jejones3141 8y ago
- dxbydt 8y agoI don’t hate R as much as I hate universities insisting on mandatory use of R for all comp-stat courses. This to my mind verges on civil rights infringements. Bear in mind we aren’t talking about a private institution such as a company, where when you sign on as a dev for a paycheck, you do so voluntarily, knowing that the company uses X language and you won’t have a choice in the matter. In a public university, students, especially grad students, who go on to do research and write papers etc., must have a choice in what they use. If I don’t like R, doesn’t matter what the reasons behind my dislike, I should have a choice. Let me use numpy, scipy.stats and pandas. How does that bother you ? First of all, you should be teaching statistical concepts, not syntax - so this whole notion that graders & TAs don’t know python is nonsense. Let them grade my numerical answers, not the R syntax used to get that answer. And at that point, how does it matter if I use R or python to get my answers ? Sorry, had to get that off my chest ( and don’t even get me started about sas )
- benmaraschino 8y agoWell, the purported civil rights issues aside (which is a patently absurd point of argument on its face) – if you’re at the point where you’ve accumulated enough experience with both environments to form strong preferences for one over the other, that’s a decent sign that said course might just not be a good fit for you. I mean, professors and TAs are pretty overloaded already, and asking them to redesign course materials to accommodate additional environments is a tall order, especially for introductory courses.
- chrfrasco 8y ago> This to my mind verges on civil rights infringements You're funny!
- edtechdev 8y agoIt's better than forcing students to pay for proprietary statistical analysis tools like SPSS, etc.
- curiousgal 8y agoThere are running jokes amongst stats students about those who resort to using SPSS and EViews. It's mostly because of the GUI as most of the students use SAS (proprietary and expensive) as well as R.
- floki999 8y agoGreat guide. R syntax is awful, no matter how you slice it and would have been the tool of choice before Python could walk. Still, it is very powerful and great to have around.
- kentinuum 8y agoR you okay?
- oblong 8y agoR-studio is one of the best IDEs, period. Documentation? R is the only ecosystem that require good documentation to submit modules to the central repository (CRAN). The language itself is hairy, with multiple, incompatible object systens, but there is a modern refined subset, just like with Perl and C++.
- wdkrnls 8y agoR is much more lisp-like than python: more functional, more emphasis on DSLs and metaprogramming, and the community is far more inviting to New comers: reminds me a lot of Racket in that regards.
- peatmoss 8y agoYes! People ask me what the best R programming book I’ve ever read is, and I like to say “How to Design Programs.” I keep thinking someday I’ll try and build some of the missing stats infrastructure in Racket. The problem at present is time and that this stuff is real work!
- wdkrnls 8y agoI don't understand why HN hates R. HN loves lisp, and R as a language shares a much greater affinity with lisp languages than python or Go do. The language was born out of the original authors reading SICP (as statisticians). Sure, many of the users of R molded it to look like what they were used to (S), but that just highlights the powerful metaprogramming capabilities of the language.
- jakubp 8y agoI won't speak for HN, but here's a tongue in cheek summary of my experience with R. I write a script. It doesn't work. I don't know why. I look at the error message, and then google for 30 minutes to understand what it really means - which parts of the code broke, why, how to fix them. Because none of the 3 things (which, why, how) is easy to get to. OK, I fix it, having learned something new (like that there are infinite special cases with almost any functions). I commit it to repo, go for coffee. In the afternoon, a colleague asks how to run that code. Well, it was a simple script, half a page, what's the problem? I take a look, and on their machine it doesn't run. We don't know why. An hour later we discover she has some R profile file with a setting that changes behavior of some standard library... and she also has different encoding set as default, and so on, and so forth... whatever. I don't know why runtime environment encoding changes behavior of code that only deals with numbers, but hey! It's interesting at least. We fix it, we are happy. A few days later I run the script again. It works. The result doesn't look right though. It's mostly zeroes. Hmm. I run it a few more times, playing around with input, trying to figure out what's up. OK, after a few minutes I realize there's lots of red color that flashes on running the script on my screen - just so fast I barely see it. It turns out half the code isn't really running, the script just ignores it though (errors do NOT stop the code from running), and keeps going. It produces partial output happily announcing it finished. That is the most serious mindfuck. Everything is OK, says the prompt, here's your 1 megabyte result of the calculation, oh, just don't look at the numbers, because I havent' really run any of the code... I couldn't find one of the functions. I sit there wondering. Which is worse: the fact that every time I try launching the script something else is happening, or the fact that the runtime environment by default will return garbage with NO warning at the end (which is the only thing you see on screen) but with a million warnings in between (which you won't see unless you have really good reflexes...). Which is worse? I decided at some point, that I want a language to fail, and to always give me the same result. An error, an exception, this should kill the program and shout as loud as possible "Won't give you anything". Also I want code that ran yesterday to run today, and to run on my colleague's machine, and on a newer version of R. This was never our experience.
- ggm 8y agoThe first time I dived into R, I was confused. The second time, I had a purpose and found enough code to copy to achieve it. I was rewarded. The third time, I had a more complex problem demanding use of JSON from Elastic Search, and found that the two packages out there in git are basically orphanware, use dplyr in extremely confusing ways, and offer little or no advantage to simplistic HTTP fetching and direct to JSON parsing. Which is a huge shame, because the idea of an elastic search abstraction is very attractive. But. "it just didn't work out of the box" I am very clear I am an R "consumer" not an R developer. But, at this point, absent Shiny and a gui, I think that Python and Numpy has as much to offer me basically. Some people say the syntax is FP friendly. I have been trying to learn FP in Haskell and I think R is about the worst notation you could invent to sell FP.
- digitalzombie 8y agoYeah I don't get these comment comparing Lisp and R rather Python and R. R is such a bad language to learn FP in.
- thousandautumns 8y agoThis is a stupendous example of someone going overboard on their criticisms in order to grandstand. R may not be the most "beautiful" language in a general perspective, but it certainly is more beautiful than Python when it comes to actual data analysis. There is nothing in R that is as ugly as even the best implemented pandas, numpy, and matplotlib code. All of the options in Python, which is generally pointed to as the "superior" language to R, feel tacked on and hackish. The real story behind most of the complaints is that they come from software developers who only rarely need to do data analysis that would require R, and therefore use it infrequently and mistake their unfamiliarity with the language with the language being bad. I also groaned at the part where the author struggled to google questions about R because of its "stupid name". I have literally never, ever had issues Googling anything about R they same way I haven't ever had issues finding answers to my questions about "Python". The author is grasping at straws, and this is a programming blog's equivalent of clickbait.
- jandrese 8y agoSome of it is undoubtedly hyperbole, but: > Index vectors like a[1] … a[4]. All indexing in R is base-one. Note that no error is thrown if you try to access a[0]; it always returns an atomic vector of the same type but of length zero, written like numeric(0) That's serious WTF right there. In general a lot of the complaints revolve around the language making error handling unnecessarily difficult which is something that will drive me up the wall with a language. I'm a fairly defensive programmer and if your language is fighting me when I'm trying to do error checking I'm not going to be happy. I can kind of understand the thinking of "just write a perl script to verify/reformat your data before passing it to R", but that doesn't help me find my own errors.
- txcwpalpha 8y agoIt's not WTF at all once you actually understand why it works that way and the benefits it provides. Subsetting in R allows for any index number to be retrieved, and if there is no value, it returns an empty value (that's what "numeric(0)" is: an empty numeric value). It's the same if you tried to access a[0] or a[90000] (in an array that doesn't have 90000 elements). This makes it easier to select multiple elements at the same time or select a range of elements; if you try to access one that doesn't exist, it just returns an empty value rather than erroring. You can also access values by negative indexes, which have another special purpose in R that make it easier to quickly manipulate/analyze the data in the array, rather than causing an error. It's just like how SQL won't throw an error if you try to do a SELECT...WHERE ID=non_existant_value, instead it will just not return any rows (or return NULL, depending on the exact query). But you wouldn't call SQL bad, you would just acknowledge that it serves different purposes and acts differently than something like Java or C. Your comment is a great example of what the parent commenter was talking about: experienced "programmers" tend to dislike R simply because they are unfamiliar with it, and it therefor does things that they do not expect. But again, that doesn't mean the language is bad, it just means the users should probably become more familiar with their tools rather than trying to use a wrench to bang on a nail.
- CharlesMerriam2 8y agoSome reading this will claim any criticism is the fault of the critic. Others will jump in claiming it is all revealing the emperor's clothing and promoting an alternate religion. A few will deconstruct the criticisms and look for the small documentation or even language changes to solve something. I applaud the final group.
- dre85 8y agoEvery error message ever written in R: "Error" Hmmmmm, okay after 20 minutes of squinting at the script I see there's a lowercase letter at the header name of the last column somewhere in the middle of the 200 lines...now we can move on to debugging the next "Error"...
- wcr3 8y agoitt: crying about some rando's opinions. dude's venting (on his own blog) after what sounds like a legitimately frustrating experience and trying turn it into a productive exercise. if that offends your delicate sensibilities, i'm sorry. consider logging off instead of grandstanding about "grandstanding."
- jdwyah 8y agoIf you have tried R and found it painful I can’t say enough good things about the “R for Data Science” book. Great overview of Tidyverse, ggplot. After 50 pages I was further along than my previous 5 years of googling and cursing.
- kasperset 8y agoI use R most of the time and I find R notebooks very data exploration friendly. It makes it easy to back and forth just like Jupyter notebook. Producing HTML files from Rmarkdown files is also analysis friendly. 99% of the time I use tidyverse with no noticeable impact on the performance. For that occasional 1%, I must admit datatable package works out really well. tidyverse pipes are so unixy that makes it easy to transition to command such as cut, head, sort and column if needed without any mental contortion. I have used Python occasionally and with method chaining, it can almost simulate the "dplyr" like syntax. However, it is hard to find some obscure statistical test out of the box which is easy in R.
- digitalzombie 8y agoI use R a lot and I have to say some of these comments are weird. 1. R and Lisp are hardly alike even if it was inspire by it. It's like saying Erlang and Prolog is very similar. If you want learn FP do it in Erlang, Lisp, Haskell, etc.. Don't do it in R, it's half baked. 2. R syntax is ugly with warts. But built in datatype like dataframe, factor type, NA (missing value notion) value, make this language much better than many languages out there for dealing with data. Subsetting dataframe is a breeze even in base R. 3. There are many many advance statistical packages only in R. GLMnet was was in R for 4-5 years before someone decided to port it to Python. You can argue that there might be alternative package. But the statistician that created ridge, elastic, etc... method made GLMnet. There are many statistician out there that just implement their latest method in R. If you want to learn a subject in statistic there is probably a book out there and it'll have an R package and code to come along with it. Next to that will be SAS. There are very few stat book with python packages. You want to learn bayesian statistic? Social Network Analysis? There's a book for it with R code and a package to do that. Good luck finding one in Python for these subfield of statistic. There's a bayesian hierarchical analysis in Ecology and that book is in R. 4. ggplot2 is amazing for static graphic. R doesn't have good dynamic graphic out there and I kinda meh with Shiney. If you hate the syntax then you may learn to appreciate it by reading it from the creator https://www.r-bloggers.com/a-simple-introduction-to-the-graphing-philosophy-of-ggplot2/ https://www.r-bloggers.com/a-simple-introduction-to-the-grap...
- sdabdoub 8y agoAbsolutely agree with #3. R is by far the most accepted and expected implementation language for statisticians. I remember reading a blog post where the author had submitted a manuscript to a statistics journal that ended up being rejected, in part, because he had implemented the code in julia instead of R. I use python for most things, but there are so many packages that can only be found in R (especially in the bioinformatics world), so it becomes a necessity.
- int_19h 8y ago> R and Lisp are hardly alike even if it was inspire by it. It's like saying Erlang and Prolog is very similar. If you want learn FP do it in Erlang, Lisp, Haskell, etc.. Don't do it in R, it's half baked. They are very alike in the underlying core design, not in how you use them. In R, everything is an expression, and every expression is a function call. Even things like assignments, if/else, or function definitions themselves, are function calls, with C-like syntactic sugar on top. You don't have to use that sugar, though! And all those function calls are represented as "pairlists", which is to say, linked lists. Exactly like an S-expr would - first element is the name being invoked, and the rest are arguments. And you can do all the same things with them - construct them at runtime, or modify existing ones, macro-style. So in that sense, R is actually pretty much just Lisp with lazy argument evaluation (which makes special forms unnecessary, since they can all be done as functions), and syntax sugar on top. Where it really deviates is the data/object model, with arrays and auto-vectorization everywhere.
- rumcajz 8y agoThe language is really ugly and painful to use. Have someone considered making a nicer language that would compile to R?
- niceperson 8y agoI thought I was the only one who hated R. Guess not. I gave up trying to make a simple repreeeesentation when I couldn't find a tutorial on how to import data into R without using fucking excel.
- haihaibye 8y agohttp://bioinfomofo.blogspot.com/2014/01/r-hard-things-are-easy-and-easy-things.html http://bioinfomofo.blogspot.com/2014/01/r-hard-things-are-ea...
- senatorobama 8y agoThis guy just made himself unhireable.
- the_anon_coward 8y ago"See and despair: x<-y (assignment) is parsed differently than x < -y (comparison)!" And that guy talks about computer science? "<-" is a single token, what is so hard about that? It is a lexing issue, not a parsing issue! Surely one cannot accuse OCaml of being written by laymen: # type r = { mutable x : int };; type r = { mutable x : int; } # let y = { x=10 };; val y : r = {x = 10} # y.x <- 100;; - : unit = () # y.x < -10;; - : bool = false
- SubiculumCode 8y agoI don't use R to write programs. I wrangle data, run analysis, and plot results. It has a great number of solid stat packages for mixed modeling, clustering, ordination, etc. That is why I use R.
- ergodiclife 8y agoTL;DR. I just have two things to say: R worshippers: "To a man with a hammer, everything looks like a nail." Interactively manipulating tables and producing visualizations is not what software engineers/programmers on HN would call "programming". Try learning a compiled programing language like C and creating a tool or three. R haters: "It doesn't matter whether the cat is black or white, as long as it catches mice." Remember, R was designed by statisticians for statisticians -- nothing more, nothing less. Try manipulating a tabular dataset and producing visualizations in R, and see how easy and painless it is. There's a good reason behind all the hype.
- Gatsky 8y agoThere are some highly productive researchers who have taken the time to write well constructed and very useable packages in R, married with meticulous documentation. The same individuals or groups of 1-3 people have also maintained said packages for 5 years or more, and regularly respond in person to queries. Two examples are ggplot2 and limma. To me, this is all the encouragement I need to use R.