5 ms·
I love R, and I think that the insight people often overlook for R's success is pretty simple: the easy things are easy. Doing hard things in R can be very har
by x0x0 13y ago
I love R, and I think that the insight people often overlook for R's success is pretty simple: the easy things are easy. Doing hard things in R can be very hard, but the easy things are easy. Eg loading a csv full of data and running a regression on it are two lines of code that are pretty easy to explain to people:
$ R
data <- read.csv(file='some_file', header=T, sep=',')
model <- lm(Y ~ COL1 + COL2 + COL3, data=data)
and if you want to use glm -- logistic regression, etc -- it's a trivial change:
model <- glm(Y ~ COL1 + COL2 + COL3, family=binomial, data=data)
It really allows people to do quite powerful statistical analyses very simply. Note that they built a dsl for specifying regression equations -- and you don't have to bother with bullshit like quoting column column names; quoting requirements are often hard to explain to new computer users.
R's other key feature is it includes a full sql-like data manipulation language to manipulate tabular data; it's so good that every other language that does stats copied it. If df is a dataframe, I can issue predicates on the rows before the comma and columns after the comma, eg
df[ df$col1 < 3 & df$col2 > 7, 'col4']
that takes my dataframe and subsets it so -- row predicates before the comma -- col1 is less than 3 and col2 is greater than 7 -- and column predicates after the comma -- just returns a new dataframe from the subset with col4 in it. It's incredibly powerful and fast.
- beejiu 13y agoI wouldn't necessarily consider the 'bracket notation' a query, and it's very un-SQL like. It's simply three vector operations which returns a boolean vector e.g. (TRUE, FALSE, TRUE, ...), which is then used to select particular indices. I think this way of operating is more familiar to statisticians.
- Myrmornis 13y agoYes it's completely unlike SQL. Rather than declaring what is wanted and being agnostic about implementation, it actually specifies the implementation of the query, and does so using data structures of length equal to the dimension of the full table, so it's completely unscalable.
- showerst 13y agoI think of this as the statistics version of PHP's <? $paragraph = 'hello world'; echo '<p>'.$paragraph.'</p>'; ?> It makes a basic tasks super easy, which allows people who don't know what they're doing to make mistakes. It's just a different philosophy that has some negatives.
- deleted 13y ago[deleted]
- guard-of-terra 13y agoThe difference perhaps is that PHP code is facing the whole hostile internet. Which is eagerly waiting you to make a single mistake to own you. R code usually isn't.