News for hackers. Stuff that matters.
Re:The R language, for programmers by minimaxir on Thursday December 04, 2014 @11:43AM (#8700110)
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.

Re:The R language, for programmers by bglazer on Thursday December 04, 2014 @02:25PM (#8701112)
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 by alaiacano on Thursday December 04, 2014 @02:43PM (#8701211)
> s1 <- data.frame(x=c(1,2,3), y=c(7,8,7),series=rep("s1", 3))

> s2 <- data.frame(x=c(1,2,3,4), y=c(6,7,6,7), series=rep("s2", 4))

> s <- rbind(s1, s2)

> qplot(x, y, data=s, geom=c('point', 'line'), color=series)

Re:The R language, for programmers by bglazer on Tuesday December 09, 2014 @02:27PM (#8725039)
Thanks. I guess this speaks more to my lack of lack of experience.
Re:The R language, for programmers by ggrothendieck on Thursday December 04, 2014 @01:16PM (#8700694)
To be clear this applies to data frames, not the language as a whole. If you are creating a data frame by reading in data then `read.table(...whatever..., as.is = TRUE)` will read in character columns as character strings and not as factors. `data.frame()` has a `stringsAsFactors` argument which can be set to `FALSE` and one can change the global default with: `options(stringsAsFactors = FALSE)` .
Re:The R language, for programmers by claytonjy on Thursday December 04, 2014 @11:50AM (#8700154)
Agreed, this was a huge pain point for me early on; I started setting the necessary option to force stringsAsCharacters rather than specifying that arg in read.csv everytime.

Edit: I had mentioned data.table as being better than dplyr for performance reasons, but it has a unique learning curve and isn't really good for beginners

Re:The R language, for programmers by craigching on Thursday December 04, 2014 @01:48PM (#8700912)
> 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 by arun_sriniv on Friday December 05, 2014 @06:26AM (#8703946)
We're in the process of adding more detailed vignettes illustrating more clearly the philosophy behind data.table's `i, j, by`. Should make things lot easier for beginners - https://github.com/Rdatatable/data.table/issues/944

data.table is not just fast, but is also more memory efficient - we want to highlight in the vignettes as well.

And timings are quite relevant even on 10 million rows: https://gist.github.com/arunsrinivasan/db6e1ce05227f120a2c9

For much larger data, check the project page: https://github.com/Rdatatable/data.table/wiki/Benchmarks-%3A...

Re:The R language, for programmers by hadley on Thursday December 04, 2014 @11:44PM (#8703044)
FWIW The performance difference is insignificant unless your working with >>10 of millions of rows.
Re:The R language, for programmers by craigching on Friday December 05, 2014 @11:28AM (#8705282)
I thought dplyr (note, not plyr, dplyr is the next iteration of plyr implemented mostly in native code) was pretty much as fast as data.table.