News for hackers. Stuff that matters.
Re:A newcomer’s (angry) guide to R by extr on Wednesday June 13, 2018 @05:09PM (#17306970)
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 by bokstavkjeks on Wednesday June 13, 2018 @05:30PM (#17307134)
It's also worth noting that R becomes much more pleasurable with the Tidyverse libraries. The pipe alone makes everything more readable.

I'm also coming from more of an office setting where everything is in Excel. I've used R to reorganize and tidy up Excel files a lot. Ggplot2 (part of the Tidyverse) is also fantastic for plotting, the grammar of graphics makes it really easy to make nice and slightly complex graphs. Compared to my Matplotlib experiences, it's night and day. Though I'd expect my experience with programming to be quite different from others' though, mainly because any code I write is basically an intermediary step before the output goes back in Excel.

That said, if anyone's interested in learning R from a beginner's level, I can recommend the book R for Data Science. It's available freely at http://r4ds.had.co.nz/ and the author also wrote ggplot2, RStudio, and several of the other Tidyverse libraries.

EDIT: I'm also currently writing my master's thesis in RMarkdown with the Thesisdown package. It's wonderful, it allows for using Latex without really knowing Latex which is great for us in business school.

Re:A newcomer’s (angry) guide to R by riskneutral on Wednesday June 13, 2018 @06:08PM (#17307417)
Tidy features (like pipes) are detrimental to performance. The best things R has going for it are data.table, ggplot, stringr, RMarkdown, RStudio, and the massive, unmatched breadth and depth of special-purpose statistics libraries. Combined, this is a formidable and highly performant toolset for data analytics workflows, and I can say with some certainty that even though “base Python” might look prettier than “base R,” the combination of Python and NumPy is not necessarily more powerful or even a more elegant syntax. The data.table syntax is quite convenient and powerful, even if it does not produce the same “warm fuzzy” feeling that pipes might. NumPy syntax is just as clunky as anything in R, if not worse, largely because NumPy was not part of the base Python design (as opposed to languages like R and MATLAB that were designed for data frames and matrices).

What is probably not a good idea (which the article unfortunately does) is to introduce people to R by talking about data.frame without mentioning data.table. Just as an example, the article mentions read.table, which is a very old R function which will be very slow on large files. The right answer is to use fread and data.table, and if you are new to R then get the hangs of these early on so that you don’t waste a lot of time using older, essentially obsolete parts of the language.

Re:A newcomer’s (angry) guide to R by roenxi on Wednesday June 13, 2018 @06:52PM (#17307694)
> Tidy features (like pipes) are detrimental to performance.

Detrimental to the runtime performance; if you happen to be reading and processing tabular data from a csv (which is all I've ever used R for, I must admit), then you get real performance gains as a programmer. For one thing, it allows a functional style where it is much harder to introduce bugs. If someone is trying to write performant code they should be using a language with actual data structures (and maybe one that is a bit easier to parallelism than R). The vast bulk of the work done in R is not going to be time sensitive but is going to be very vulnerable to small bugs corrupting data values.

Tidyverse, and really anything that Hadley Wickham is involved in, should be the starting point for everyone who learns R in 2018.

> languages like R and MATLAB that were designed for data frames and matrices

Personal bugbear; the vast majority of data I've used in R has been 2-dimensional, often read directly out of a relational database. It makes a lot of sense why the data structures are as they are (language designed a long time ago in a RAM-lite environment), but it is just so unpleasant to work with them. R would be vastly improved by /single/ standard "2d data" class with some specific methods for "all the data is numeric so you can matrix multiply" and "attach metadata to a 2d structure".

There are 3 different data structures used in practice amongst the R libraries (matrix, list-of-lists, data.frame). Figuring out what a given function returns and how to access element [i,j] is just an exercise in frustration. I'm not saying a programmer can't do what I want, but I am saying that R promotes a complicated hop-step-jump approach to working with 2d data that isn't helpful to anyone - especially non-computer engineers.

Re:A newcomer’s (angry) guide to R by rpier001 on Wednesday June 13, 2018 @10:11PM (#17308710)
I think what you're saying is mostly on point. I wanted to share a couple possible balms for your bugbears.

For attach metadata to an anything, why not use attributes()/attr() or the tidy equivs? Isn't that what it is for?

It might not make you feel much better, but data.frame is just a special list, c.f. is.list(data.frame()). So, if you don't want to use the connivence layers for data.frame you can just pretend it is a list and reduce the ways of accessing data structures by one.

You can paper over the distinction between data.frames and matrices if it comes up for you often enough. E.g.

`%matrix_mult%` <- function(x,y) { if("data.frame" %in% class(x)) { x <- as.matrix(x) stopifnot(all(is.numeric(x))) } if("data.frame" %in% class(y)) { y <- as.matrix(y) stopifnot(all(is.numeric(y))) } stopifnot(dim(x)[2] == dim(y)[1]) x %*% y }

d1 %matrix_mult% d2

... but I'll grant that isn't the language default.

Re:A newcomer’s (angry) guide to R by roenxi on Thursday June 14, 2018 @02:39AM (#17309790)
I wrote a function once for a friend that modified the enclosing environment, and changed + so that sometimes it added two numbers together and sometimes it added to numbers and an extra 1 just to be helpful. I can sort myself out, but thanks for the thoughts.

The issue is that I learn these things /after/ R does something absolutely off the wall with its type system. And a lot of my exposure comes from using other people's libraries.

For my own work I just use tidyverse for everything. It solves all my complaints, mainly by replacing apply() with mutate(), data.frame with tibble and getting access to the relational join commands from dplyr. I'll cool with the fact my complaints are ultimately petty.

> For attach metadata to an anything, why not use attributes()/attr() or the tidy equivs? Isn't that what it is for?

I've never met attr before, and so am unaware of any library that uses attr to expose data to me. The usual standard as far as I can tell is to return a list.

> It might not make you feel much better, but data.frame is just a special list, c.f. is.list(data.frame()). So, if you don't want to use the convenience layers for data.frame you can just pretend it is a list and reduce the ways of accessing data structures by one.

Well, I could. But data frames have the relational model embedded into them, so all the libraries that deal with relational data use data frames or some derivative. I need that model too, most of my data is relational.

The issue is that sometimes base R decides that since the data might not be relational any more it needs to change the data structure. Famously happens in apply() returning a pure list, or dat[x, y] sometimes being a data frame or sometimes a vector depending on the value of y. It has been a while since I've run in to any of this, because as mentioned most of it was fixed up in the Tidyverse verbs and tibble (with things like its list-column thing).

> `%matrix_mult%` <- function(x,y) { if("data.frame" %in% class(x)) { x <- as.matrix(x) stopifnot(all(is.numeric(x))) } if("data.frame" %in% class(y)) { y <- as.matrix(y) stopifnot(all(is.numeric(y))) } stopifnot(dim(x)[2] == dim(y)[1]) x %*% y }

I have got absolutely no idea what that does in all possible edge cases, and to be honest if the problem that is solving isn't actually one I confront often enough to look in to it.

It just bugs me that I have to use as.matrix() to tell R that my 2d data is all made up of integers, when it already knows it is 2d data (because it is a data frame) and that it is made up of integers (because data frame is a list of vectors, which can be checked to be integer vectors). I don't instinctively see why it can't be something handled in the background of the data.frame code, which already has a concept of row and column number. Having a purpose-built data type only makes sense to me in the context that at one point they used it to gain memory efficiencies.

I mean, on the surface

data %>% select(-date) %>% foreign_function() and data %>% select(-date) %>% as.matrix %>% foreign_function()

look really similar, but changing data types half way through is actually adding a lot of cognitive load to that one-liner, because now I have to start thinking about converting data structures in the middle of what was previously high-level data manipulation. And you get situations that really are just weird and frustrating to work through, eg, [1].

[1] https://emilkirkegaard.dk/en/?p=5412

Re:A newcomer’s (angry) guide to R by rpier001 on Thursday June 14, 2018 @09:03AM (#17311317)
scale() for example uses attributes to hold on to the parameters used for scaling. Most packages that use attributes provide accessor functions so that the useR doesn't need to concern themselves with how the metadata are stored. I'll grant that people do tend to use lists because the access semantics are easier.
Re:A newcomer’s (angry) guide to R by kazinator on Wednesday June 13, 2018 @08:48PM (#17308353)
If you're in a situation where 80% of the time is spent in 20% of the code, you only have to use less expressive features in those hot-spots; you don't have to give up your pipes or whatever in places that don't contribute much to the run-time.
Re:A newcomer’s (angry) guide to R by com2kid on Wednesday June 13, 2018 @08:44PM (#17308336)
> Tidy features (like pipes) are detrimental to performance.

But they are some absolutely amazing features to use. After helping my wife learn R, and learning about all the dypler features, going back to other languages sucked. C#'s LINQ is about as close as I can get to dypler like features in a main stream language.

Of course R's data tables and data frames are what enable dypler to do its magic, but wow what magic it is.

Re:A newcomer’s (angry) guide to R by wodenokoto on Thursday June 14, 2018 @02:57AM (#17309877)
I think your autocorrect mangled up your `dplyer`s :)
Re:A newcomer’s (angry) guide to R by com2kid on Thursday June 14, 2018 @04:14PM (#17314960)
Hah! I even looked it up, then typed it wrong.

I keep trying to type something that is actually pronounceable! ;)

Re:A newcomer’s (angry) guide to R by stewbrew on Thursday June 14, 2018 @12:24AM (#17309269)
Can you backup your performance claim? The last time I checked a benchmark that compared dplyr vs DT, DT didn't come out as a winner.
Re:A newcomer’s (angry) guide to R by riskneutral on Thursday June 14, 2018 @08:13AM (#17311031)
Here is one example: https://appsilondatascience.com/blog/rstats/2017/03/02/r-fas...

I also base this on my own experience. I typically work with 2-3 million row datasets. I found that doing certain data operations was quite slow in plyr but a lot faster in data.table. It’s possible that if I had spent time reordering my plyr pipelines and filtering out unneeded columns or rows, then it would have worked better. However, data.table doesn’t require such planning ahead and thinking about what columns/rows you need to send to the next operation in a pipeline, because multiple operations can be executed from a single data.table call, and the underlying C library is able to make optimized decisions (like dropping columns not requested in the query), similar to an in-memory SQL database. So between dealing with slow code while doing interactive analysis, and/or having to spend time hand-optimizing dplyr pipelines, I found data.table to be a significant improvement in productivity (other than the one-time effort of having to rewrite a few internal packages/scripts to use data.table instead of dplyr)

Re:A newcomer’s (angry) guide to R by stewbrew on Thursday June 14, 2018 @10:20AM (#17311848)
Thanks for the reference. Why don't you keep your data in a DB? I load almost anything that isn't a small atomic data frame into a RDBMS.

BTW one thing that always made me avoid DT (I even preferred sqldf before dplyr was created) was its IMHO weird syntax. I always found the syntax of (d)plyr much more convenient. ATM it seems to me that dplyr has won the contest of alternative data management libraries. I cannot remember when I last read a blog post, article, or book that preferred DT over dplyr. I'm old enough to have learned that wrt libraries, it's wise to follow the crowd.

Re:A newcomer’s (angry) guide to R by stewbrew on Thursday June 14, 2018 @10:42AM (#17312071)
About that article: I assume that DT uses an index for that column while dplyr does a full search. If that's really the case the result wouldn't be that much a surprise.
Re:A newcomer’s (angry) guide to R by curiousgal on Wednesday June 13, 2018 @06:37PM (#17307590)
From your experience what makes data.table so useful?
Re:A newcomer’s (angry) guide to R by vijucat on Wednesday June 13, 2018 @07:44PM (#17308015)
Answering questions in a rapid, interactive way (, while using C to be efficient enough that one can run it on millions of rows):

  # Given a dataset that looks like this…
  > head(dt, 3)
      mpg cyl disp  hp drat    wt  qsec vs am gear carb          name
  1: 21.0   6  160 110 3.90 2.620 16.46  0  1    4    4     Mazda RX4
  2: 21.0   6  160 110 3.90 2.875 17.02  0  1    4    4 Mazda RX4 Wag
  3: 22.8   4  108  93 3.85 2.320 18.61  1  1    4    1    Datsun 710
  
  # What's the mean hp and wt by number of carburettors?
  > dt[, list(mean(hp), mean(wt)), by=carb]
     carb    V1     V2
  1:    4 187.0 3.8974
  2:    1  86.0 2.4900
  3:    2 117.2 2.8628
  4:    3 180.0 3.8600
  5:    6 175.0 2.7700
  6:    8 335.0 3.5700
  
  # How many Mercs are there and what's their median hp?
  
  > dt[grepl('Merc', name), list(.N, median(hp))]
     N  V2
  1: 7 123

  # Non-Mercs?
  > dt[!grepl('Merc', name), list(.N, median(hp))]
      N  V2
  1: 25 113

  # N observations and avg hp and wt per {num. cylinders and num. carburettors}

  > dcast(dt, cyl + carb ~ ., value.var=c("hp", "wt"), fun.aggregate=list(mean, length))
     cyl carb hp_mean  wt_mean hp_length wt_length
  1:   4    1    77.4 2.151000         5         5
  2:   4    2    87.0 2.398000         6         6
  3:   6    1   107.5 3.337500         2         2
  4:   6    4   116.5 3.093750         4         4
  5:   6    6   175.0 2.770000         1         1
  6:   8    2   162.5 3.560000         4         4
  7:   8    3   180.0 3.860000         3         3
  8:   8    4   234.0 4.433167         6         6
  9:   8    8   335.0 3.570000         1         1


I used slightly verbose syntax so that it is (hopefully) clear even to non-R users.

You can see that the interactivity is great at helping you compose answers step-by-step, molding the data as you go, especially when you combine with tools like plot.ly to also visualize results.

Re:A newcomer’s (angry) guide to R by int_19h on Thursday June 14, 2018 @04:11AM (#17310187)
What a lot of people don't get is that this kind of code is what R is optimized for, not general purpose programming (even though it can totally do it). While I don't use R myself, I did work on R tooling, and saw plenty of real world scripts - and most of them looked like what you posted, just with a lot more lines, and (if you're lucky) comments - but very little structure.

I still think R has an atrocious design as a programming language (although it also has its beautiful side - like when you discover that literally everything in the language is a function call, even all the control structures and function definitions!). It can be optimized for this sort of thing, while still having a more regular syntax and fewer gotchas. The problem is that in its niche, it's already "good enough", and it is entrenched through libraries and existing code - so any contender can't just be better, it has to be much better.

Re:A newcomer’s (angry) guide to R by extr on Wednesday June 13, 2018 @09:23PM (#17308514)
Completely agree. dplyr is nice enough but the verbose style gets old fast when you're trying to use it in an interactive fashion. imo data.table is the fastest way to explore data across any language, period.
Re:A newcomer’s (angry) guide to R by riskneutral on Thursday June 14, 2018 @08:21AM (#17311073)
I strongly agree, having worked quite a bit in several languages including Python/NumPy/Pandas, MATLAB, C, C++, C#, even Perl ... I am not sure about Julia, but last time I looked at it, the language designers seemed to be coming from a MATLAB type domain (number crunching) as opposed to an R type domain (data crunching), and so Julia seemed to have a solid matrix/vector type system and syntax, but was missing a data.table style type system / syntax.
Re:A newcomer’s (angry) guide to R by ChrisRackauckas on Thursday June 14, 2018 @09:36AM (#17311549)
Julia v0.7-alpha dropped and it has a new system for missing data handling. JuliaDB and DataFrames are two tabular data stores (the first of which is parallel and allows out-of-core for big data). This has changed pretty dramatically over the last year.
Re:A newcomer’s (angry) guide to R by hobolord on Wednesday June 13, 2018 @09:00PM (#17308409)
the grammar of data.table is a bit similar to SQL, and I find that it's easier to quickly write something vs piping in dplyr
Re:A newcomer’s (angry) guide to R by newen on Wednesday June 13, 2018 @10:34PM (#17308811)
Plus I don't have to remember a lot of function names and what order to input vars to the functions. Just have a remember the data.table index syntax and I can do a lot of stuff. I'm sure I can do dplyr once I learn the functions but the data.table syntax seems very simple and elegant to me.
Re:A newcomer’s (angry) guide to R by maxander on Wednesday June 13, 2018 @09:31PM (#17308554)
No, you are wrong. R is terrible, and especially so for non-professional programmers, and it is an absolute disaster for the applications where it routinely gets used, namely statistics for scientific applications. The reason is its strong tendency to fail silently (and, with RStudio, to frequently keep going even when it does fail.) As a result, people get garbage results without realizing, and if they're unlucky, these results are similar enough to real results that they get put somewhere important. Source: I'm a CS grad working with biologists; I've corrected errors in the R code of PhD'd statisticians, in "serious" contexts.

Scientific applications require things to fail hard and often, to aggressively fail whenever anything is potentially behaving incorrectly. R does the exact opposite of that in several different, pernicious ways. IMHO, Python is more dangerous than a scientific computing language should be, but at least it will stop when it hits an error. R has undoubtedly cost humanity millions of dollars in wasted research costs and caused untold confusion, from otherwise perfectly-performed studies reporting corrupted statistical results. The world would be a noticeably better place without it.

I simply cannot articulate my opinion about R without sounding grossly hyperbolic. I'm sad that HN, a place which is typically enlightened in the ways of the programming arts, is so confused what this article is on about. If we tolerate such blatantly hostile design in something as important as the language of scientific statistics, where do we expect to get?

Re:A newcomer’s (angry) guide to R by rpier001 on Wednesday June 13, 2018 @09:51PM (#17308637)
Have you ever worked with other major statistical packages? Have you ever caught people doing data munging in Excel? R fails far less silently than the credible alternatives. Source: I've been around the academic block and seen many types of horrors.

It's unfortunate that you've gotten to a _terrible_ feeling about R without realizing that many of the 'silent' failures are easily configured away (some examples, https://github.com/hadley/strict). That R isn't noisy about things that CS majors might think it should be by default is, BTW, entirely appropriate. Many of what one might call 'silent' failure modes in R are for the express purposes of making exploratory data analysis easier... and that was one of the original purposes for R.

Re:A newcomer’s (angry) guide to R by extr on Wednesday June 13, 2018 @10:10PM (#17308703)
That's too bad, I wish R could be better and easier for these people, but I don't think it warrants your hyperbole. I can point to many of my own anecdotes where R has saved millions of dollars by empowering analysts to conduct data exploration and modeling that would have been vastly more complex undertakings using any other tool. They seem to handle the silent failures just fine (usually by double checking their results before presenting them). Poor rigor and coding practices in academia are practically a meme at this point. You really want to lay all of that at the feet of R? Suggest a code review step for their publishing process or use a different tool. R is certainly not perfect but the idea that "The world would be a noticeably better place without it" is silly.
Re:A newcomer’s (angry) guide to R by safgasCVS on Thursday June 14, 2018 @01:22AM (#17309497)
R is fundamentally flawed. It tries to merge two highly conflicting goals: a productive analytics environment and a programming language.

To do the first really well means automating away many of the issues that would crop up in the second allowing R to 'just work'. Because of that nothing beats R for getting to an answer as fast as possible (not even Python) at the cost of making it more difficult to productionise a solution in pure R.

Given its huge popularity and free-nature the benefits clearly outweigh the costs by a large factor.

Re:A newcomer’s (angry) guide to R by keymone on Friday June 15, 2018 @09:49AM (#17319729)
Not sure I buy this. R is a language with parser and interpreter. Parser spits out an AST and interpreter evaluates nodes according to rules. This is the same in every other sane language. AST is pretty much the same in every language. There is no reason R’s parser and language can’t be replaced with something sane.

And it really is insane and horrible.

Re:A newcomer’s (angry) guide to R by SubiculumCode on Thursday June 14, 2018 @04:55AM (#17310346)
And there is the mistake: production. Most people I know who use R don't care a whit about production. They run an analysis to answer hypotheses.
Re:A newcomer’s (angry) guide to R by zhdc1 on Thursday June 14, 2018 @06:13AM (#17310575)
I agree that R shouldn't be used in production, but R is great for prototyping different analytical models before porting them over to Python or another language.
Re:A newcomer’s (angry) guide to R by safgasCVS on Thursday June 14, 2018 @06:50AM (#17310703)
Same here and I think that’s exactly how its meant to be used.

Even so, if you want to use R as the production system, you shouldn’t implement the jumbled spaghetti code an iterative analysis involves just for your own sanity's sake. A rewrite is always required at which point hello Python

Re:A newcomer’s (angry) guide to R by zrobotics on Thursday June 14, 2018 @12:37AM (#17309322)
While I kind of want to agree with you, I just don't see a better alternative. Do you really want biochemists to have to deal with the horrors of C compilation? In production code I'm very glad my makefile tells clang to fail on absolutely anything, but is that the best we can do? Other commenters have pointed out ways to avoid dangerous things like integer division, but if you think R is hostile then please offer a tenable alternative. The only ones I can think of are python and Matlab, and both are even worse for the intended use.

Yes, R is not my preferred language for anything heavy-duty, but I would guess ~95% of R usage is on datasets small enough to open in excel, and that is where the language truly shines (aside from being fairly friendly to non-programmers).

So yes, there are some problems with R, but what are your proposed improvements? Because if I have to analyze a .csv quickly, I'm going for R most of the time.

Re:A newcomer’s (angry) guide to R by teekert on Thursday June 14, 2018 @05:02AM (#17310376)
Python3: Pandas ans Seaborn?

I have very quick flows for data processing: load data, make long form, add meta data as categories, plot many things with seaborn one-liners. I use Jupyter lab and treat it Like a full lab notebook, including headers, introduction, conclusion, discussion. Works very wel for me.

Re:A newcomer’s (angry) guide to R by ScottBurson on Thursday June 14, 2018 @12:56AM (#17309393)
> I just don't see a better alternative

Julia?

Re:A newcomer’s (angry) guide to R by jghn on Thursday June 14, 2018 @01:12AM (#17309464)
The biggest Julia cheerleaders gave up years ago. That doesn't mean the language is dead but it's not a great sign for a niche lang
Re:A newcomer’s (angry) guide to R by Xcelerate on Thursday June 14, 2018 @04:38AM (#17310284)
Julia is by far my favorite language; I used it all throughout grad school for my research. The problem is that it doesn't have enough of a network effect in industry. I've begrudgingly switched to Python for my day-to-day work.
Re:A newcomer’s (angry) guide to R by int_19h on Thursday June 14, 2018 @04:13AM (#17310194)
Actually, what is the current status of Julia? Can anyone in the know share a bit on the perspectives as they stand?
Re:A newcomer’s (angry) guide to R by Sean1708 on Thursday June 14, 2018 @05:30AM (#17310455)
They're in the run-up to their first stable release at the moment (I think they're aiming for August, but could be wrong about that). I can't speak for popularity, but development is certainly going strong.
Re:A newcomer’s (angry) guide to R by ChrisRackauckas on Thursday June 14, 2018 @09:37AM (#17311560)
The biggest Julia cheerleaders are using Julia.
Re:A newcomer’s (angry) guide to R by pfortuny on Thursday June 14, 2018 @04:36AM (#17310276)
uf, I’m a working mathematician and just reading julia’s documentarion makes me dizzy... I do not think it fits this use case.
Re:A newcomer’s (angry) guide to R by newen on Thursday June 14, 2018 @08:40AM (#17311163)
Re:A newcomer’s (angry) guide to R by pfortuny on Thursday June 14, 2018 @09:19AM (#17311436)
Sure, thanks. I am always put off Julia because of the documentation.
Re:A newcomer’s (angry) guide to R by dnautics on Thursday June 14, 2018 @10:30AM (#17311940)
That's ironic because I find Julia's documentation to be the second most clear documentation I've seen (after elixir). Notation wise, Julia is the most comfortably close to mathematics (APL is closer, but it's a write only language). I'm not a working mathematician, though i did graduate with a rather theory based math degree.
Re:A newcomer’s (angry) guide to R by ChrisRackauckas on Thursday June 14, 2018 @11:01AM (#17312223)
The documentation is fine but IMO written more for developers. We do need more mathematical-based introductions which introduce the right packages for working mathematicians. I am a working mathematician myself and find Julia to be the perfect language for it because its abstraction is on actions instead of on data representations which fits things like functional analysis extremely well.

Things that are OO based like C++ and Python are pretty bad at representing math because they put forward an idea of the actual representation (the object) as what matters, instead of the actions it performs (the function overloads). This may be good for some disciplines, but in a mathematical algorithm I really don't care what kind of matrix you gave me for `A`, I just want you to do the efficient `Ax=b` solve and have the action of the solver choose the appropriate method to abstract away the data. In Python you'd have to tell it to use the SciPy banded matrix solver, in Julia your generic ODE solver will automatically use the banded matrix solver when it's a banded matrix. This then allows for a composibility where the user overloads the primitive operations on their type, and your generic algorithm works on any data representation. This matches the workflow of math where an algorithm is proven on L2 functions, not on functions represented with column-wise indexing and ...

Re:A newcomer’s (angry) guide to R by dnautics on Thursday June 14, 2018 @09:59PM (#17316959)
I've written a custom GF256 data type and used Julia's builtin matrix solves (note: required monkey patching in Julia <~ 0.6 because there were one and zero literals in the builtin solver) to do Reed Solomon erasure coding... It's glorious.
Re:A newcomer’s (angry) guide to R by stewbrew on Thursday June 14, 2018 @12:19AM (#17309253)
You're right and wrong: R is a disaster when you want to write programs as you would in a real programming language. R is an excellent choice for what it is used most of the time by these people whose education/training isn't related to programming: interactive analysis of data and (maybe) writing prototypes.
Re:A newcomer’s (angry) guide to R by duncan_bayne on Thursday June 14, 2018 @06:21AM (#17310600)
My brief encounter with R led me to the exact same conclusion - that the R culture does not value correctness. That is not a characteristic I value in a development culture.

Case in point, the bug I raised about TZ handling (which is also an example of silent failure):

https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16412

Re:A newcomer’s (angry) guide to R by mr_toad on Wednesday June 13, 2018 @11:23PM (#17309015)
Silent failure and continuing to run on errors are common in interpreted languages. SAS has similar issues, most RDBMSs will continue to process queries after failures. It’s something you need to explicitly guard against.
Re:A newcomer’s (angry) guide to R by electrum on Thursday June 14, 2018 @12:48AM (#17309361)
Are you sure about "most RDBMSs"? With the exception of SQLite and older versions of MySQL, all the databases that I've used are strict and fail the query immediately on error, will generally prevent silently dropping or truncating data, etc.

I'm one of the original authors of Presto, a distributed SQL engine for analytics on big data. From the beginning, we've been careful to follow the SQL standard and do everything possible to either return the correct answer or fail the query. For example, an addition or sum aggregation on an integer will fail on overflow rather than silently wrapping.

Returning an incorrect answer or silently corrupting your data is the worst thing a database can do.

Re:A newcomer’s (angry) guide to R by mr_toad on Thursday June 14, 2018 @04:10AM (#17310180)
What I mean is that if you run in batch mode they’ll fail a query and happily run the next. Generally, depending on the client, you need to handle begin/commit/rollback blocks yourself. This is pretty common in scripting languages. Unlike, for example Java, where an unhandled error will terminate the process.
Re:A newcomer’s (angry) guide to R by psychometry on Thursday June 14, 2018 @10:40AM (#17312047)
You haven't been working with scientists very long, have you? I'm guessing you're also only a very recent CS grad. You're criticizing a language based on the behavior of certain people who use the language, rather than criticizing the language itself.

For many years before you mounted your high horse, scientists were writing equally shitty code in Perl. When they've moved on from R, they'll write shitty code in some other language.

Re:A newcomer’s (angry) guide to R by md2be on Wednesday June 13, 2018 @11:33PM (#17309073)
Completely disagree
Re:A newcomer’s (angry) guide to R by joker3 on Wednesday June 13, 2018 @05:51PM (#17307305)
The thing to keep in mind is that, from the point of view of someone who works with data, R isn't a programming language. It's a statistical software package that has a programming language. Its competitors are things like Minitab, SPSS, Stata, and JMP, all of which used to be entirely menu-driven. R was a genuine innovation when it was first introduced.

Now it's certainly showing its age and the limits of its design, but it's still best in class for a certain kind of user. We could do better for software development, but it's not clear that doing so would actually make data analysis easier.

Re:A newcomer’s (angry) guide to R by yodsanklai on Wednesday June 13, 2018 @06:45PM (#17307659)
> 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

To me, the opposite is true. People with no CS background would benefit the most from a simple design.

> in R, data types are pretty fungible, everything is a vector, coercing things generally "just works".

Things just work until they don't, and then you need to understand all the weirdness of R.

I don't know what's the typical experience of a non-programmer with R, but as a programmer, I had some headache trying to understand R semantics (apparently I'm not the only one [1]).

[1] http://r.cs.purdue.edu/pub/ecoop12.pdf

Re:A newcomer’s (angry) guide to R by extr on Wednesday June 13, 2018 @09:34PM (#17308570)
I have a lot of experience teaching non-programmers R. Most of them come from an Excel/SQL background. I have found the amount of weirdness that presents a real problem is very low. And when it does get weird, I usually advise we just brush it under the rug and use a different method to accomplish the same thing. This probably sounds horrifying, but it's really not. Most of the code people write in R is not like other programming languages, it's rarely bound for anything other than the end user's laptop, if its even saved in the first place.
Re:A newcomer’s (angry) guide to R by crispyambulance on Wednesday June 13, 2018 @07:36PM (#17307958)
I use R at least a couple times a week. It gets the job done and I will be forever grateful for the tidyverse.

That said, R can be goddamn frustrating at times because of the way the documentation is written. It would be nice to simply be able to query about a function and get a cogent help file that explains THE BASICS of how to use the function for the most common use-case(s). Instead, the help files try to be "canonical" and front-load a bunch useless technical detail-- like that something is an "S3" object. Still haven't figured out what that really means and, I expect, that knowing something is "S3" will NEVER help me out when I am in a jam and need a little help to do something simple because I forgot some data manipulation detail.

Instead, I end up googling all the time connecting the dots all over the internet to get very simple stuffs done. At least now we have stackoverflow which, as vicious as it is, seems like Mister Rogers' Neighborhood compared to the old R mailing list.

Re:A newcomer’s (angry) guide to R by ekianjo on Wednesday June 13, 2018 @08:00PM (#17308116)
The documentation varies a lot by the package. Some libraries have excellent help files, while others are poorly written. At best, its inconsistent.
Re:A newcomer’s (angry) guide to R by newen on Wednesday June 13, 2018 @05:25PM (#17307086)
Yes a couple of years ago I did this project where I needed to get a ton of analysis done, typically with plots and tables as output. Did this in python and it was this huge mess with pandas and matplotlib. Re-did it in R with data.table and ggplot2 and it was just ridiculously easier, and I could expand upon the code much more easily, plus the output was much prettier.
Re:A newcomer’s (angry) guide to R by Avshalom on Wednesday June 13, 2018 @05:31PM (#17307143)
>>Have you ever tried explaining the various python package and environment management options to someone with a background in Excel/SQL?

Yes, well, from the outside it doesn't seem like Python programmers have any better grasp of those either.

Re:A newcomer’s (angry) guide to R by vertere on Thursday June 14, 2018 @05:37AM (#17310473)
You might be right. Whereas programmers tend to regard languages as something to be understood, package managers are something they just use ("if it works, it works"). Typical R users (i.e. data analysts) regard languages a bit like programmers regard package managers.
Re:A newcomer’s (angry) guide to R by Giroflex on Wednesday June 13, 2018 @06:03PM (#17307380)
> 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?

I don't understand the difficulty I've often seen voiced against this. Why would a newbie or someone who just wants to get analytical work done need anything beyond installing Python and doing `pip install library`? It's certainly orders of magnitude easier and faster than, say, using a C library. The only trouble I can see a newbie running into is if they want to install a library which doesn't have precompiled wheels and they need some dependencies to build it, but that's rarely an issue for popular packages.

Re:A newcomer’s (angry) guide to R by CJefferson on Wednesday June 13, 2018 @07:58PM (#17308100)
Well pip install library needs root, which you probably don't have. So now you have to teach them about making, and acitvating, virtual environments.

Also, they can't easily search through the packages in a nice GUI and just click on the one they want to install.

Re:A newcomer’s (angry) guide to R by Giroflex on Wednesday June 13, 2018 @09:21PM (#17308498)
>pip install library needs root

Hmm, not really. It's actually advised against [1].

[1] - https://askubuntu.com/questions/802544/is-sudo-pip-install-s...

Re:A newcomer’s (angry) guide to R by newen on Wednesday June 13, 2018 @10:48PM (#17308875)
Pip install needs root on my ubuntu install, my lab's and university's old redhat servers and my windows for linux install. I've had to install anaconda python to get any real work done on all three systems. Anaconda works fine for me but I've not even had to think about anything to install packages in R.
Re:A newcomer’s (angry) guide to R by sdabdoub on Thursday June 14, 2018 @01:28AM (#17309521)
try

    pip install --user
or virtualenvs
Re:A newcomer’s (angry) guide to R by rspeer on Thursday June 14, 2018 @02:50AM (#17309845)
Ubuntu doesn't ship with pip or virtualenv. In fact it ships with a version of Python where the built-in equivalent to virtualenv, pyvenv, is explicitly disabled.

So you have to install extra Python packages, as root. You have to have that Python experience that guides you to install as few of them as you can, just enough so you can get started with a virtualenv, so you don't end up relying on your system Python environment.

And this is really hard to explain to people who aren't deeply familiar with Python. "Never use sudo to install Python packages! Oh, you got errors. We obviously meant use sudo for two particular packages and never again after that."

In the terrible case where you don't have root, you have to ignore Ubuntu's version of Python and compile it yourself from scratch. Hope the right development libraries are installed!

Maybe I'm wrong and there's a method I've overlooked. If there is: please show me how to install a Python package on a fresh installation of Ubuntu 16.04, without ever using sudo, and I will happily spread the good news.

Re:A newcomer’s (angry) guide to R by int_19h on Thursday June 14, 2018 @04:25AM (#17310230)
That sounds like a major problem with Ubuntu, rather than with Python or pip.

On Windows, meanwhile, the standard Python installer gets all this set up properly in like three clicks. Better yet, because it installs per-user by default, "pip install" just works. And if you still choose to install it globally, it will fail, but it will tell you exactly what you need to do to make it work:

    Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: ...
    Consider using the `--user` option or check the permissions.
One can't help but wonder how we ended up in a situation where the most popular Linux distro somehow does Python worse than Windows.
Re:A newcomer’s (angry) guide to R by angry_octet on Thursday June 14, 2018 @09:18AM (#17311424)
Don't despair, in the Anaconda installed with visual studio (now a default) you can't update or install packages without being admin! And if you install Anaconda again it merges the start menu entries and you can't tell which is which...
Re:A newcomer’s (angry) guide to R by YeGoblynQueenne on Thursday June 14, 2018 @05:15AM (#17310411)
Eh, that has always been the case for windows vs linux, that you don't have to compile anything yourself because there is always an installer that will deploy precompiled binaries for whatever you want to install (except for when there isn't, because nobody has compiled it for windows, at which point you're in deeper shit) (or except when something installs itself but doesn't update your envars, so you have to do it yourself, which kind of defeats the purpose of the whole "installer" thing).
Re:A newcomer’s (angry) guide to R by int_19h on Friday June 15, 2018 @03:59AM (#17318197)
You don't need to compile anything yourself on Linux either - that's what package managers are for.
Re:A newcomer’s (angry) guide to R by YeGoblynQueenne on Friday June 15, 2018 @05:55AM (#17318620)
Iiish. For small projects or when you want to get development versions etc that are not in a distro's repos it's pretty common to have to do a make-configure.

Then again, with Python in particular, I have often had errors either with pip-install, or after "successful" installation, for various reasons.

Re:A newcomer’s (angry) guide to R by int_19h on Friday June 15, 2018 @07:14PM (#17324517)
In this case, we were talking about Python itself. I don't see any particular reason why most people should need to build it themselves, whether on Windows or on Linux. Packages are another matter, but here the issue is the way Python itself is packaged on Ubuntu.
Re:A newcomer’s (angry) guide to R by orbifold on Thursday June 14, 2018 @02:05AM (#17309657)
This is not really thinking though, just a ~3 hour commitment once to figure out how it is supposed to work.
Re:A newcomer’s (angry) guide to R by Sean1708 on Thursday June 14, 2018 @06:15AM (#17310585)
Not on a personal computer, no, but the vast majority of managed systems won't let you install anything outside of your home directory. Of course you could install using `pip install --user` but you will inevitably run into problems when something you install locally needs an updated version of something installed on the system.
Re:A newcomer’s (angry) guide to R by mr_toad on Wednesday June 13, 2018 @11:32PM (#17309064)
Makes it fun when running on a VM in the cloud which only has a root user. Docker becomes almost essential to preventing errant Python scripts fudging up the system.
Re:A newcomer’s (angry) guide to R by nzjrs on Thursday June 14, 2018 @02:05AM (#17309655)
This is bad advice. Pip should be used in virtual environments, and not to install system packages
Re:A newcomer’s (angry) guide to R by txcwpalpha on Thursday June 14, 2018 @02:23AM (#17309719)
While you're right that it's bad advice, it also highlights the problem with pip that these less experienced people have. The ideal way to deal with Python packages is virtualenvs, but setting up a virtualenv, and then activating it every time you want to use it (or setting up tools to do it for you) is an incredibly huge headache for less experienced people to deal with. R doesn't require that whatsoever.
Re:A newcomer’s (angry) guide to R by jupiter90000 on Thursday June 14, 2018 @02:51AM (#17309851)
Neither language requires an isolated dev environment, but it can help with avoiding headaches. As python has things like virtualenv and buildout, fortunately R has 'packrat' available, which provides a similar isolated/reproducible dev environment solution.

https://rstudio.github.io/packrat/

Re:A newcomer’s (angry) guide to R by int_19h on Thursday June 14, 2018 @04:14AM (#17310202)
There's nothing wrong with pip for installing per-user packages outside of virtual environments.
Re:A newcomer’s (angry) guide to R by ekianjo on Wednesday June 13, 2018 @08:02PM (#17308127)
And pip s upgrade process for packages is almost non existent, while R supports that very, very easily.
Re:A newcomer’s (angry) guide to R by Giroflex on Wednesday June 13, 2018 @09:24PM (#17308519)
Never had any trouble with `pip install --upgrade library`.

Not sure if there's support for upgrading all packages at once, though.

Re:A newcomer’s (angry) guide to R by ekianjo on Thursday June 14, 2018 @12:10AM (#17309215)
There is no such support for multiple packages at once. R can do it though.
Re:A newcomer’s (angry) guide to R by scaryclam on Thursday June 14, 2018 @06:45AM (#17310681)
You can certainly update multiple packages at once using pip. Just use a requirements.txt file, which you should be doing anyway if you're using multiple packages (or just want to be able to reproduce your environment).
Re:A newcomer’s (angry) guide to R by YeGoblynQueenne on Thursday June 14, 2018 @05:29AM (#17310451)
>> Why would a newbie or someone who just wants to get analytical work done need anything beyond installing Python and doing `pip install library`? It's certainly orders of magnitude easier and faster than, say, using a C library.

Except when it isn't. For instance, because some wheel fails to build because you're lacking the VC++ redistributable (or it's not where pip thinks it should be):

  C:\Users\YeGoblynQueenne\Documents\Python> pip install -U spacy
  Collecting spacy
    Downloading spacy-1.2.0.tar.gz (2.5MB)
      100% |################################| 2.5MB 316kB/s
  Collecting numpy>=1.7 (from spacy)
    Downloading numpy-1.11.2-cp27-none-win_amd64.whl (7.4MB)
      100% |################################| 7.4MB 143kB/s
  Collecting murmurhash<0.27,>=0.26 (from spacy)
    Downloading murmurhash-0.26.4-cp27-none-win_amd64.whl
  Collecting cymem<1.32,>=1.30 (from spacy)
    Downloading cymem-1.31.2-cp27-none-win_amd64.whl
  Collecting preshed<0.47.0,>=0.46.0 (from spacy)
    Downloading preshed-0.46.4-cp27-none-win_amd64.whl (55kB)
      100% |################################| 61kB 777kB/s
  Collecting thinc<5.1.0,>=5.0.0 (from spacy)
    Downloading thinc-5.0.8-cp27-none-win_amd64.whl (361kB)
      100% |################################| 368kB 747kB/s
  Collecting plac (from spacy)
    Downloading plac-0.9.6-py2.py3-none-any.whl
  Requirement already up-to-date: six in c:\program files\anaconda2\lib\site-packages (from spacy)
  Requirement already up-to-date: cloudpickle in c:\program files\anaconda2\lib\site-packages (from spacy)
  Collecting pathlib (from spacy)
    Downloading pathlib-1.0.1.tar.gz (49kB)
      100% |################################| 51kB 800kB/s
  Collecting sputnik<0.10.0,>=0.9.2 (from spacy)
    Downloading sputnik-0.9.3-py2.py3-none-any.whl
  Collecting ujson>=1.35 (from spacy)
    Downloading ujson-1.35.tar.gz (192kB)
      100% |################################| 194kB 639kB/s
  Collecting semver (from sputnik<0.10.0,>=0.9.2->spacy)
    Downloading semver-2.7.2.tar.gz
  Building wheels for collected packages: spacy, pathlib, ujson, semver
    Running setup.py bdist_wheel for spacy ... error
    Complete output from command "c:\program files\anaconda2\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\yegobl~1\\appdata\\local\\temp\\pip-build-7o0roa\\spacy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'ex
  ec'))" bdist_wheel -d c:\users\yegobl~1\appdata\local\temp\tmpypkonqpip-wheel- --python-tag cp27:
    running bdist_wheel
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\spacy
    copying spacy\about.py -> build\lib.win-amd64-2.7\spacy

    [217 lines truncated for brevity]

    copying spacy\tests\sun.tokens -> build\lib.win-amd64-2.7\spacy\tests
    running build_ext
    building 'spacy.parts_of_speech' extension
    error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
  
    ----------------------------------------
    Failed building wheel for spacy
    Running setup.py clean for spacy
    Running setup.py bdist_wheel for pathlib ... done
    Stored in directory: C:\Users\YeGoblynQueenne\AppData\Local\pip\Cache\wheels\2a\23\a5\d8803db5d631e9f391fe6defe982a238bf5483062eeb34e841
    Running setup.py bdist_wheel for ujson ... error
    Complete output from command "c:\program files\anaconda2\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\yegobl~1\\appdata\\local\\temp\\pip-build-7o0roa\\ujson\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'ex
  ec'))" bdist_wheel -d c:\users\yegobl~1\appdata\local\temp\tmp8wtgikpip-wheel- --python-tag cp27:
    running bdist_wheel
    running build
    running build_ext
    building 'ujson' extension
    error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
  
    ----------------------------------------
    Failed building wheel for ujson
    Running setup.py clean for ujson
    Running setup.py bdist_wheel for semver ... done
    Stored in directory: C:\Users\YeGoblynQueenne\AppData\Local\pip\Cache\wheels\d6\df\b6\0b318a7402342c6edca8a05ffbe8342fbe05e7d730a64db6e6
  Successfully built pathlib semver
  Failed to build spacy ujson
  Installing collected packages: numpy, murmurhash, cymem, preshed, thinc, plac, pathlib, semver, sputnik, ujson, spacy
    Found existing installation: numpy 1.11.0
      Uninstalling numpy-1.11.0:
        Successfully uninstalled numpy-1.11.0
    Running setup.py install for ujson ... error
      Complete output from command "c:\program files\anaconda2\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\yegobl~1\\appdata\\local\\temp\\pip-build-7o0roa\\ujson\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, '
  exec'))" install --record c:\users\yegobl~1\appdata\local\temp\pip-ibtvwu-record\install-record.txt --single-version-externally-managed --compile:
      running install
      running build
      running build_ext
      building 'ujson' extension
      error: Microsoft Visual C++ 9.0 is required (Unable to find vcvarsall.bat). Get it from http://aka.ms/vcpython27
  
      ----------------------------------------
  Command ""c:\program files\anaconda2\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\yegobl~1\\appdata\\local\\temp\\pip-build-7o0roa\\ujson\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --recor
  d c:\users\yegobl~1\appdata\local\temp\pip-ibtvwu-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\yegobl~1\appdata\local\temp\pip-build-7o0roa\ujson\
Now that's newbie scary.

Note that this is just one case where I was trying to install one particular package. I got a couple more examples like this in my installation diary, notably one when I tried to install matplotlib, this time on Windows Subystem for Linux, a.k.a. Ubuntu, and hit a conda bug that meant I had to use an older version of QT until upstream fixed it and other fun times like that.

Re:A newcomer’s (angry) guide to R by yread on Thursday June 14, 2018 @01:45AM (#17309584)
> install RStudio and are off to the races, with a helpful package installation GUI.

Unless the package needs a native component like libcurl of particular version then it can turn into couple of hours of blindly trying everything you can think of.

> Another great example: in R, data types are pretty fungible, everything is a vector,

Unless it's a dataframe or factor or string or s3, s4 or s5 or a couple of other things.

And the documentation will tell you the reference paper that you can read and some completely impractical example.

Ugh, feels better now, sorry for the rant.

Re:A newcomer’s (angry) guide to R by shawnz on Thursday June 14, 2018 @02:48AM (#17309830)
> 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.

This implies we strive for good design in languages just because it appeases some ideal we have about how languages should be. But really we strive for good design in languages because it makes them more powerful, more expressive, easier to use, etc. Sure, maybe Python doesn't have all the right abstractions to be perfectly suited to statistical tasks, whereas R has more natural abstractions for that kind of stuff. But that doesn't mean that R doesn't also have many objectively bad design decisions even for statistical uses.

Re:A newcomer’s (angry) guide to R by acomjean on Wednesday June 13, 2018 @05:20PM (#17307046)
As a datapoint in agreement. Some of the Biologists I work with love R. I had one tell me that its like how they think, and they weren't a python fan.

I think R-Studio (an R based IDE that turns it kinda into a more excel like experience) where you can inspect the data in memory (including matrix data) and graph making is where it really helps bring people into the R language. And with a set of instructions anyone can go load the analysis packages and do their data analysis.

Compare this to python, where they have to go the unix shell set up the environment, load the libraries. When they come back reset everything and get back to where they started.

Re:A newcomer’s (angry) guide to R by ekianjo on Wednesday June 13, 2018 @08:05PM (#17308140)
You can also use R in Jupyterlab these days and while its quite different from RStudio it is quite practical to conduct data exploration.
Re:A newcomer’s (angry) guide to R by angry_octet on Thursday June 14, 2018 @09:26AM (#17311480)
Anaconda and Jupyter is a much more friendly environment than straight writing .py files, much like r studio. It lacks the integrated debugging features, though vscode does provide some rudimentary assistance. I'd say it's superior overall, especially in regard to getting help and documentation.
Re:A newcomer’s (angry) guide to R by gbrown on Wednesday June 13, 2018 @05:38PM (#17307196)
Another feature for this audience is the philosophy that functions shouldn't have side effects. You can still do (several types) of object oriented programming in R, but it does take away some of the ways in which non-programmers shoot themselves in the foot.

I've come to really like the way environments work in R, as well.

Re:A newcomer’s (angry) guide to R by mr_toad on Wednesday June 13, 2018 @11:38PM (#17309092)
A sane language shouldn’t need three different object systems.
Re:A newcomer’s (angry) guide to R by gbrown on Thursday June 14, 2018 @01:21PM (#17313347)
Meh, S3 is nice and lightweight for a very particular kind of analysis interoperability. S4 isn't super useful IMHO. RC is very well thought out, and I've heard good things about R6. It might not be sane language design, but it works well for designing very different kinds of analytical procedures.
Re:A newcomer’s (angry) guide to R by randomsearch on Thursday June 14, 2018 @03:26AM (#17309995)
Good point about the package management, but I disagree with your argument. Non-Computer Scientists seem to have a much easier time with Python than R, anecdotally.

I think the reason is that R is not just a badly designed language, but in particular its design is inconsistent. That’s as confusing to newcomers as it is to people who care about PL design.

I used R for almost a decade. Last year I switched to Python and Jupyter, never looked back. Can’t recommend the switch highly enough. R has great stats packages, but struggling with the language is just not worth it.

Re:A newcomer’s (angry) guide to R by jghn on Thursday June 14, 2018 @01:10AM (#17309460)
I came from a "real" programming background. This was pre-Tidyverse. Learning R thoroughly was the best thing I could have ever done for my proglang understanding as all the weird things R had meant that every time I learned something new I could say "Oh, it's like X in R".
Re:A newcomer’s (angry) guide to R by Animats on Thursday June 14, 2018 @02:31AM (#17309756)
HN is predisposed to hate R because everyone here is coming from a "real" programming context.

There is that. Matlab has the same problem.

One problem with "real programming languages" is that programmers who grew up with C don't see any need for built-in multidimensional arrays. This is one reason FORTRAN is still around, and why array work is straightforward in Matlab and R.

Re:A newcomer’s (angry) guide to R by int_19h on Thursday June 14, 2018 @04:13AM (#17310196)
It seems to be partly because they're rarely used in general purpose code even when they are there. Just look at C#.
Re:A newcomer’s (angry) guide to R by killjoywashere on Wednesday June 13, 2018 @07:45PM (#17308016)
> though Anaconda is getting better with this

Anaconda is becoming to python what Chrome is to browsers, particularly as Jupyter matures. Drop it in, and a huge amount of what you want to do is ready to go. Sure, there's lots of libraries/extensions available, but most of the time you can do real work with a default userland, non-privileged install.

Re:A newcomer’s (angry) guide to R by ekianjo on Wednesday June 13, 2018 @07:56PM (#17308085)
And there is litterally no equivalent to dplyr and ggplot2 in Python. Those alone can make a huge difference in how many lines you need to write to do something.
Re:A newcomer’s (angry) guide to R by asteriske on Wednesday June 13, 2018 @08:39PM (#17308302)
ggplot2 has plotnine (http://plotnine.readthedocs.io) which has a nearly identical API. I've found though it's not perfect, you can get closer to dplyr with JS-style method chaining on Pandas.
Re:A newcomer’s (angry) guide to R by tincholio on Thursday June 14, 2018 @03:36AM (#17310052)
I've recently used plotnine, and it's been a relatively good experience, but Pandas is absolute garbage compared to the tidyverse, API-wise.
Re:A newcomer’s (angry) guide to R by ekianjo on Thursday June 14, 2018 @12:11AM (#17309224)
I tried plotnine before and its far from covering everything ggplot can do. And chaining on pandas can make things unreadable compared to dplyr.
Re:A newcomer’s (angry) guide to R by Thriptic on Wednesday June 13, 2018 @06:23PM (#17307514)
I actually totally agree with this. I learned how to program in R and found it to be quite wonderful to use as a noob. As you say, shit just works. If you think you should be able to do an operation, you typically can. To this day I still prefer cleaning and doing proof of concept analyses in R rather than Python. It's so much easier than having to fuck with pandas and numpy.
Re:A newcomer’s (angry) guide to R by educationdata on Wednesday June 13, 2018 @09:42PM (#17308602)
One common thing across most the "real" programming languages makes them unfit for data work: 0-based indexing.

It is just ridiculous to call the first row in a data set as 0th row, and the last row as (n-1)th row. It does not make any sense for data analytic work.

Re:A newcomer’s (angry) guide to R by bograt on Wednesday June 13, 2018 @09:53PM (#17308646)
I'm not sure I understand this, and I'm genuinely interested in why it would be.

I find zero indexing logical: zero is the first natural number and is thus a fine candidate for being the first ordinal.

In my experience most mathematical series lose nothing in terms of elegance or readability by being indexed from zero instead of using more traditional indexing from one.

Re:A newcomer’s (angry) guide to R by tnecniv on Thursday June 14, 2018 @12:43AM (#17309345)
Generally I've found you carry around fewer n +/- 1 type expressions when you index from 1. Also, most applied math papers I've read index from 1 and that makes implementing them a lot easier.
Re:A newcomer’s (angry) guide to R by Sean1708 on Thursday June 14, 2018 @06:32AM (#17310642)
> Generally I've found you carry around fewer n +/- 1 type expressions when you index from 1.

I've actually found the opposite, though admittedly it doesn't come up often enough to be a major nuisance.

Re:A newcomer’s (angry) guide to R by dnautics on Thursday June 14, 2018 @10:44AM (#17312090)
Generally 1 is considered the first natural number, except bourbaki.

The reason for this is the set {1...n} has order n, but the set {0...n} has order n+1, so you get lots of off by n+1 inelegancies or errors when order is important. It's better to be explicit at the set level when you need an {0...n-1} set, because usually the order gets passed around to later expressions and not the set element, so there's less algebra.

Zero indexing is great when your index is an offset, as it is for true arrays.

Re:A newcomer’s (angry) guide to R by goatlover on Wednesday June 13, 2018 @10:40PM (#17308843)
You find zero indexing logical most likely because you learned programming on languages which are zero-based. But most of the rest of the population, including statisticians, for which R is the intended audience, likely start at one and aren't used to OB1 errors.
Re:A newcomer’s (angry) guide to R by newen on Wednesday June 13, 2018 @10:40PM (#17308848)
It seems needlessly confusing to me to refer to the first number in a series as the 0th number. 0-based indexing is only good for offset counting, which is very much based on having a mental model based on pointer arithmetic for a number sequence.
Re:A newcomer’s (angry) guide to R by samatman on Wednesday June 13, 2018 @11:56PM (#17309167)
Which years are in the decade the Twenties?
Re:A newcomer’s (angry) guide to R by newen on Thursday June 14, 2018 @12:39AM (#17309331)
Yeah years start at 0. But that's because it measures the offset from the beginning of the calendar. You can similarly expand this to all distance based measurements. But that is completely different from counting, which shouldn't be conflated with distances. People always say the first of some sequence and only people who care about 0-based indexing tries to spread the 0th of some sequence meme.
Re:A newcomer’s (angry) guide to R by ako on Thursday June 14, 2018 @01:10AM (#17309458)
Which days are in a Month? You dont start with june 0th and end with june 29th?
Re:A newcomer’s (angry) guide to R by samatman on Thursday June 14, 2018 @12:27PM (#17312834)
I would if I could!
Re:A newcomer’s (angry) guide to R by samatman on Thursday June 14, 2018 @12:31PM (#17312871)
I may as well amuse myself here:

My ideal calendar has 12 30 day months, days 0 to 29.

If it's 10th June and you have an appointment for 0 August, that's 50 days from now.

At the end of the year, a 5 or 6 day 'month' called Holiday. 30th December becomes Christmas Day (observed) and 0 January is still New Years. New Years Eve is either 5 or 6 Holiday.

6 Holiday would be a lot of fun. ^_^

Re:A newcomer’s (angry) guide to R by tincholio on Thursday June 14, 2018 @03:32AM (#17310026)
Re:A newcomer’s (angry) guide to R by webelo on Thursday June 14, 2018 @12:31AM (#17309287)
I think this comment reflects the fact that a lot of pen and pencil linear algebra/stats/econometrics all uses one-based indexing.

There are a few times where I’ve had to formally write out a zero-based indexing scheme of a given expression because python indexing can seem so weird in this case. For example, “lag zero” just sounds like a funny way of talking about lag 1 (to me). Of course, if you’re predicting y_t+1 then it sort of makes sense that y_t[+0] would be paired with B_0.

Then there is the whole thing about how, say, range(5) will return 0,1,2,3,4 and NOT 5.

All of this makes sense once you use python for a while but if you spend most of your time writing with pencil then it will probably take some adjustment.

Re:A newcomer’s (angry) guide to R by niceperson on Thursday June 14, 2018 @02:34AM (#17309766)
This is really stupid. Language decisions coming from a background native to them are always superior. This isn't a matter of "all opinions are equal". They never are. R is horrendous, plain and simple.
Re:A newcomer’s (angry) guide to R by durbatuluk on Wednesday June 13, 2018 @08:39PM (#17308303)
As someone who taught R for students coming from Biology. Most of them just want to learn some_stat_test(), how to interpret it and who to plot().

These who tried to do modeling using vanilla R just dropped midway because of R performance and switched back to fortran

ggplot2 just should be baseline instead of default gfx.

Re:A newcomer’s (angry) guide to R by itronitron on Thursday June 14, 2018 @01:49AM (#17309595)
I am always amazed when I hear that people use Python in any type of production pipeline.
Re:A newcomer’s (angry) guide to R by terragon on Thursday June 14, 2018 @03:09AM (#17309928)
Could you please elaborate on that?

My company has tons of python code producing reports with reportlab, making UIs with PyQt5, as well as a multitude of small scripts to interact with MySQL.

We’ve been nothing but happy with Python in the years of using it.

Re:A newcomer’s (angry) guide to R by itronitron on Thursday June 14, 2018 @08:28PM (#17316524)
Mainly because production pipelines care a great deal about performance (speed) and Python is generally considered to have worse performance in comparison to compiled languages (Java or C++.) Depending on your pipeline that may not be a big deal.
Re:A newcomer’s (angry) guide to R by YeGoblynQueenne on Thursday June 14, 2018 @04:35AM (#17310273)
"I 've done it so it's not so bad" is not a very good argument. I've done a significant data science project in Prolog (with R for the plotting btw) but that doesn't mean Prolog is the go-to language for data science :)
Re:A newcomer’s (angry) guide to R by shakna on Thursday June 14, 2018 @05:30PM (#17315552)
But it is a datapoint against the hypothesis "Prolog is inappropriate for data science".
Re:A newcomer’s (angry) guide to R by YeGoblynQueenne on Friday June 15, 2018 @05:47AM (#17318585)
Oh, true that :) Sorry, I might have misread your comment!
Re:A newcomer’s (angry) guide to R by leibnitz27 on Thursday June 14, 2018 @03:04AM (#17309902)
^^ THIS. And yet certain organisations I know have upwards of 40M lines of it. Run. Run. Run FASTER.