Live data from Hacker News

The R language, for programmers

johndcook.com

41–50 of 79 posts

Re: The R language, for programmers

#41

The biggest "gotcha" for learning R as a programmer is that R interprets character vectors of data frames as factor vectors by default , which will usually break something in your code. If you're learning R, learn to use dplyr for data manipulation and ggplot2 for plotting. Both will save you a lot of time.

> If you're learning R, learn to use dplyr for data manipulation

I had been learning data.table, but I really like dplyr's % operator and the compositional functions better. I think I'm going to make the move to dplyr.

Re: The R language, for programmers

#42
post #29

Earlier quoted context omitted.

Python has better and better support for R with Rpy2 and R like data frames with Pandas, which is helping me take advantage of the incredibly useful analysis libraries in R. Also note that loops are slow enough that it is really worth learning the *apply() functions in R to avoid iterating over collections. For a relatively in depth explanation check out Hadley Wickham's book http://adv-r.had.co.nz/Functionals.html

*apply functions are loops underneath -- they only look better and save you time possibly wasted on growing some dynamically sized output structure. The way of solving slow loop in R is to find package which implements it in C/Fortran (or write your own in case there is none).

It'a actually a little complicated but if you're interested in the details check out this stack overflow thread [1]. High level summary is that lapply() and functions built on top of it do some work in native C and so are generally faster but not all of the *apply() functions are faster.

[1] http://stackoverflow.com/questions/2275896/is-rs-apply-famil...

Re: The R language, for programmers

#43
The language might experience the 'peak R' point right now.

'Badass' statistic packages but R always felt a bit 'hacked together'. With Julia on the other hand, I get the impression that there are developers in charge which have a deep understanding about programming languages and computer science. It's (too) early times for Julia but I wouldn't be surprised if in two years many users will (partly) switch.

Re: The R language, for programmers

#44
post #2

I actually quite like the R language. A buddy of mine is in his University's PoliSci program and one of the requirements is to learn R for statistical and trend analysis. He could not stop complaining until I offered to help him learn it by learning it with him. After doing his first assignment, we were both impressed with what could be easily done in R to visualize data. I think he now realizes how useful of a tool…

If I just want to learn Statistical Programming, is R good for that? I can't afford/not willing to buy SAS or Matlab.

Re: The R language, for programmers

#45
post #8

R is one of those languages that looks like it was designed in a vacuum by a very smart person. It has many common, modern PL constructs, but they're expressed syntactically in a way that in no way resembles any other language I've seen. The entire syntactic legacy of Algol, Pascal, C, etc, all are thrown by the wayside. Familiarity with any of those syntaxes felt to me like more of a liability than a help. That's no…

R is a 'rip-off' / open source re-implementation of the commercial S language by John Chambers. (There are some differences in scoping iirc). Haven't many of its 'modern' PL constructs already been used in Lisp (dialects) before?

Re: The R language, for programmers

#46

I find R to be a great language for exploring a data set and doing some prototyping. There are a lot of wonderful statistical tools available through the core packages and even more through the various community extensions. It does have some significant issues that I've found limit the usefulness outside of prototyping - pass by value only means code tends to end up as monolithic functions - very slow in loops so lot…

For ggplot - there is (sort of) a clone of it for Python, https://github.com/mwaskom/seaborn. And it has, arguably, better graphics.

As a Python user, who resorts to R in case of need, the power of R is not in the language, but statistical community & packages.

Re: The R language, for programmers

#47

The biggest "gotcha" for learning R as a programmer is that R interprets character vectors of data frames as factor vectors by default , which will usually break something in your code. If you're learning R, learn to use dplyr for data manipulation and ggplot2 for plotting. Both will save you a lot of time.

I've heard all good things about ggplot2 and I sincerely believe they're true. However, my only experience has been trying to plot 2 overlapping timeseries that didn't have the same length to the same plot area. I found that to be nearly impossible in ggplot2 and almost trivial with the builtin plot and lines commands in R.

Like a lot of good tools, it seems that ggplot2 makes the common case extremely easy, but it can be a struggle to make it work in uncommon situations.

Re: The R language, for programmers

#48
post #44
post #2

I actually quite like the R language. A buddy of mine is in his University's PoliSci program and one of the requirements is to learn R for statistical and trend analysis. He could not stop complaining until I offered to help him learn it by learning it with him. After doing his first assignment, we were both impressed with what could be easily done in R to visualize data. I think he now realizes how useful of a tool…

If I just want to learn Statistical Programming, is R good for that? I can't afford/not willing to buy SAS or Matlab.

Yes, it is. The language itself is free and the runtime environment can be downloaded for free. There's even a good IDE for it called R Studio, which has a good free version.

R is based on S, which itself was purely designed as a statistical programming language.

Re: The R language, for programmers

#50
When reading this article, I started to wonder whether it would be plausible to create a REPL or a compiler from some "real" programming language (like, I don't know, C#, C++ or Python) to R to utilize R's statistical libraries without going insane. This might be a fun exercise as an LLVM backend. :)
Post reply on HN