Live data from Hacker News

The Zen of R

gist.github.com

21–28 of 28 posts

Re: The Zen of R

#21

Earlier quoted context omitted.

Aside: One of the things that I really don’t like about R coming from a background in other programming languages is that a function is evaluated before its arguments; i.e. an expression passed as a parameter to a function is not a value but is an implicit lambda, to be evaluated multiple times somewhere inside the function. For example: replicate(2, rnorm(2)) creates a 2x2 matrix of independent random values. Wherea…

R does have call-by-need semantics, like (an impure) Haskell, but that's not why replicate's second argument gets evaluated multiple times: replicate The replicate function uses R's compute-on-the-language to construct a new function that has expr as its body. A closure's argument will be evaluated at most once.

[deleted]

Re: The Zen of R

#22
post #13

I love R, but it can be frustrating to code with and learn. Some of its datatypes are immensely powerful but work in mysterious ways. It allows you to manipulate expressions in a LISP macro-like fashion which, when used badly by library authors, can make many things appear magical (and inconsistant). There are many inconsistencies in the standard library because of different programming paradigms used (for example (s…

Map and subset would be discouraged, they are just wrappers around the apply functions and [] anyway.

Re: The Zen of R

#23

This is slick...but: How often do you want to generate random walks of this type where the variance of the process isn't dependent on its current level? Observe that, as you increase the standard deviation of the random normal (to even .1), your "random walk" always walks to zero. I don't mean to be a beady-eyed-pterodactyl but, as cool as clever one-liners sometimes are, often they solve toy problems. I say this as…

That's an interesting point. In fact, the expectation of the random walk is always the same as its starting value, because, although most of the walks go to 0 like you observed, there are very occasionally walks that drift upward to astronomical values.

As for the usefulness of this kind of walk: the process we're modelling is an evolutionary one, where the rate of change is fixed (in this case within the species) and we'd like to detect 'random' (non-selected) evolutionary paths by comparing simulations to historical data.

Re: The Zen of R

#24
Slightly OT: I'd be really interested to hear a list of specific advantages to using R over using scipy. I have been holding off on learning R for years because scipy has served my purposes pretty well so far, but sometimes I wonder what I'm missing.

Re: The Zen of R

#25

Slightly OT: I'd be really interested to hear a list of specific advantages to using R over using scipy. I have been holding off on learning R for years because scipy has served my purposes pretty well so far, but sometimes I wonder what I'm missing.

The extent of my experience with R was a couple of somewhat introductory statistics courses, so I’m not the best person to answer probably.

But I like dealing with numpy/scipy much, much more than R. Python as a language is I think much better designed, and numpy is a really nice tool for interacting with multidimensional arrays. When I write Python code, or read Python code written by anyone competent, I find program intent very easy to design/follow. Most of the R code I’ve seen “in the wild” is kind of a mess, because it is written by non-programmers many of whom have little experience or concept of code style. Additionally, as soon as a program has to do anything other than statistical analysis (examples: text munging, internet scraping, network communication, dealing with file formats, user interaction, etc.) Python is miles ahead.

The big advantages of R that I saw: (1) it has become the tool of choice in the academic statistics community, meaning that there is quite a lot of existing code for doing various sophisticated things, some of which you might have to implement yourself in Python, (2) it has some really nice graphing tools, (3) there seemed to be a few examples where a particular few lines of R code were more compact and clearer than the equivalent Python (can’t think of anything off-hand though).

Re: The Zen of R

#26

Slightly OT: I'd be really interested to hear a list of specific advantages to using R over using scipy. I have been holding off on learning R for years because scipy has served my purposes pretty well so far, but sometimes I wonder what I'm missing.

I'm not really a big fan of R but I have found it to be advantageous to use for some things. In particular, the big advantage of R is the huge user community. You can find a huge number of packages to use for many non-trivial tasks. Also the graphics tools are in my opinion superior to scipy.

Re: The Zen of R

#27
post #13

I love R, but it can be frustrating to code with and learn. Some of its datatypes are immensely powerful but work in mysterious ways. It allows you to manipulate expressions in a LISP macro-like fashion which, when used badly by library authors, can make many things appear magical (and inconsistant). There are many inconsistencies in the standard library because of different programming paradigms used (for example (s…

Map and subset would be discouraged, they are just wrappers around the apply functions and [] anyway.

I wouldn't discourage them uniquivocally - for instance, 'subset' is an idiom often used in the context of data/relational tables. That matters a little bit (enough to pay a little penalty in raw performance), I would think.

Re: The Zen of R

#28

Slightly OT: I'd be really interested to hear a list of specific advantages to using R over using scipy. I have been holding off on learning R for years because scipy has served my purposes pretty well so far, but sometimes I wonder what I'm missing.

I'm a pythonist - use it all the time. Except when I need to do some stats or graphing, and then it's R all the way. The R language is ugly, and warty, but it's awesomely powerful. Hell, the graphing library ggplot2 (http://had.co.nz/ggplot2/) is worth it by itself.
Post reply on HN