Live data from Hacker News

A newcomer’s (angry) guide to R

arrgh.tim-smith.us

11–20 of 232 posts

Re: A newcomer’s (angry) guide to R

#11
post #2

I think many of the gotchas and annoying parts of base R are solved by using tools from the 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...

That 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-...

Re: A newcomer’s (angry) guide to R

#12

Having 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.

My 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.

Re: A newcomer’s (angry) guide to R

#13

Having 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.

My 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.

This is game changing. Thanks, I can't wait to try this out.

Re: A newcomer’s (angry) guide to R

#14

>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”,…

> 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 )

>> 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)

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

Re: A newcomer’s (angry) guide to R

#15
As 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 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.

Re: A newcomer’s (angry) guide to R

#16
I 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 !!!

Re: A newcomer’s (angry) guide to R

#17

Earlier quoted context omitted.

> 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 )

>> 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 ) 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 an…

It was my interpretation of the original article quote that it was referring to tidy schema, but I could be incorrect. (the gather() function of tidyr names its parameters key and value as well, and the function is described as "Gather columns into key-value pairs": http://tidyr.tidyverse.org/reference/gather.html)

Re: A newcomer’s (angry) guide to R

#18

Having 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.

ggplot2 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).

Re: A newcomer’s (angry) guide to R

#19
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.

Re: A newcomer’s (angry) guide to R

#20
There 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.

Post reply on HN