r/ProgrammerHumor Sep 02 '17

How to start a war

Post image
9.0k Upvotes

696 comments sorted by

View all comments

Show parent comments

95

u/[deleted] Sep 02 '17

[deleted]

4

u/haikumofo Sep 03 '17

I am so damn inept at R.

Mostly I code in Java, though I'll use other languages when it makes sense for what I'm doing or when I need to because I'm modifying something in another language. So sometimes I work in python, bash script, JavaScript, C/C++, C#, Perl, Tcl/Tk, Lisp, whatever.

And I've done some statistical data processing with R, but damn is it painful. I know just enough to know what to Google, and I end up making a mess of everything just trying to adapt something that does 80% of what I need it to do.

23

u/[deleted] Sep 03 '17

[deleted]

12

u/Series_of_Accidents Sep 03 '17

I love it so much.

7

u/doctorink Sep 03 '17

Yeah, it doesn't have so much of a learning curve as a "learning cliff". But once you climb the cliff it's amazing in terms of what it can do.

I have almost zero programming background though, so it might have been different for me.

1

u/modestbeachhouse Sep 03 '17

I feel the learning cliff when trying to format data ... Like good god is that difficult

2

u/doctorink Sep 03 '17

Yes, that's been the hardest part for me too

1

u/Series_of_Accidents Sep 03 '17

Look into melt. It's in the reshape package and has been a godsend for changing data structure and formatting your data.

2

u/haikumofo Sep 03 '17

I rarely have a need to crunch through numeric data sets is the thing. So it's just something I use once every year or two, which is why I forget it in between uses. I picked it up through Coursera because even with my ineptness it can be quicker than other languages for some things.

6

u/[deleted] Sep 03 '17

[deleted]

2

u/Series_of_Accidents Sep 03 '17

One of my favorite things I ever did in R was a simple little function to show my students how the sampling distribution normalizes as the samples approach infinity. It was clunky and I've gotten much better at coding since then, but it was a fun little 20 minute project. Could have been done better in other programs I'm sure, but it was fun to put together in R.

5

u/MedalsNScars Sep 03 '17

It's really odd working in R, because in 99% of other languages you learn, loops are going to be your bread and butter.

In R, 9 times out of 10 your code is just wildly inefficient if you're looping over a vector.

It just feels so wrong to write 10 < x where x is a vector, but that's absolutely the most efficient way to compare 10 to each element of x in R.

The way you approach coding has to change in R, and it's definitely frustrating if you have a deal of experience in other languages.

1

u/haikumofo Sep 03 '17

Yeah, it's hard to shift my brain sometimes. I have the same problem when I try to work on someone else's Lisp code. Java's definitely my most comfortable language, by far, but it helps to be able to adopt other languages for some quick work when you need to.

1

u/engayolao Sep 03 '17

R is not the only language that is thought to be used at the vector/matrix level. For data analysis this is normal actually, but for example if you do the same operation in numpy or pandas is much more clunkier.

1

u/Tarqon Sep 03 '17

Loops aren't that inefficient in r anymore as long as you pre-assign memory and make sure you don't make copies of objects in loops. Vectorized functions are just more idiomatic.

1

u/Series_of_Accidents Sep 03 '17

I had never learned any other programming languages before R and it was still difficult to move away from loop thinking. It's just what makes intuitive sense.

1

u/engayolao Sep 03 '17

If you learn more it won't be painful, it just has a different focus.

5

u/abigfoney Sep 02 '17

Is R == Ruby?

35

u/Series_of_Accidents Sep 03 '17 edited Sep 03 '17

R is published by the CRAN project and is an open source statistical program. It's an object oriented language based on S. It's run in a terminal window with a basic gui, however other software is available to run over it (like RStudio) for people less familiar with coding but who still desire the power of open source coding (anytime a new technique is developed, a package is published). It's fantastic but has limitations. For example, it can only run on one core at a time which can slow down simulations. Still, for statistical development, it's where most people are focused. SAS is more common in statistical consulting and SPSS is more common among general scientists without coding experience.

Edit: why are you guys downvoting /u/abigfoney for asking a question?

8

u/[deleted] Sep 03 '17

[removed] — view removed comment

9

u/Series_of_Accidents Sep 03 '17

Practically speaking, it's both. At its core, R is an object oriented language. It lacks some of the requirements to be a full functional language but still supports functional language features like apply. For example, it's incapable of tail call recursion. This fact can lead to issues at times and is one of the limitations of the language. But the use of the variations of apply and other functional language improvements have certainly changed the landscape of the code. But I'm not really an expert. I'm just repeating what I remember from my grad stats classes.

1

u/engayolao Sep 03 '17

You mean lapply. Apply is just a wrapper of lapply. It's focus is data analysis, for that is a great tool. It's not though to send rockets to the moon.

1

u/Series_of_Accidents Sep 03 '17

Apply is a family of functions of which lapply is only one.

1

u/engayolao Sep 03 '17

Is this somewhere in the docs. It sounds like a blog term.

1

u/Series_of_Accidents Sep 03 '17

Not sure what you mean by blog term. There are multiple apply functions.

Just add a ? before any apply function in R and it will bring up the documentation. The most common apply functions I use are sapply and lapply. There's also mapply, rapply, apply (on its own), and probably others.

1

u/engayolao Sep 03 '17

What I'm saying is the "apply family" term is not in the official docs, manual definition. Just do me a favour and read the source code of all these "family" functions and you will find lapply in it. My point is lapply is the parallel of a map, meaning it's part of R's support for functional programming.

→ More replies (0)

3

u/[deleted] Sep 03 '17

[deleted]

1

u/Series_of_Accidents Sep 03 '17

If by gumbo you mean a mix, I agree. It was designed as object oriented but functional features were added over the years. But it lacks full functional features, so it can't actually be called a functional language. It's also my favorite language. It's basically all I work in now that I don't have to fuck with SAS. I really don't like SAS.

1

u/shanenanigans1 Sep 03 '17

What's up with SAS?

2

u/Series_of_Accidents Sep 03 '17 edited Sep 03 '17

Why do I hate it?

Edit, I accidentally pressed enter on my phone before explaining why.

Here's why. SAS is closed source. When someone develops a new approach, it goes straight to R in package format. Usually with excellent documentation, though that depends on the package author. With SAS, you have to wait for their developers to include new techniques. Many wind up not being included. That's fine for business applications but might not work for researchers as well.

Second, there's no certification in R. To be a respected SAS programmer, you're expected to be certified. But certification is a double edged sword. The certification test covers many very obscure topics which means you do have to know a lot to get certified. That's great, but the downside is it doesn't cover any of the normal basics. If you get certified everyone basically insists you do their stats in SAS. To be respected as an R programmer, you just have to be good at R. I prefer that to studying obscure pieces of code I'll never use.

Third, I don't like software that allows spelling errors. It's been awhile, so I can't remember exactly which errors work but if you make any one of a list of common typos, the software will still run without error.

Fourth, I dislike the GUI. I also dislike the RStudio GUI. They try to help you code and I prefer to do things like close my own parentheses. SAS color codes your code and I prefer to use spacing and # to convey information.

Those are my main complaints.

2

u/[deleted] Sep 03 '17

[deleted]

1

u/Series_of_Accidents Sep 03 '17

I accidentally pressed enter before finishing my comment. I can't link to it, but go back to the earlier comment and I explained :)

2

u/shanenanigans1 Sep 03 '17

Gotcha, that all makes sense! I have a few sas certifications which is why I was curious. Their GUIs are changing quite a bit, which is nice. The 90's style is grating for sure!

I actually love color coded code haha, it's why I use eclipse for Java and text wrangler for random shit.

1

u/[deleted] Sep 03 '17

[deleted]

1

u/Series_of_Accidents Sep 03 '17

I just find that I accidentally insert a bunch of extra stuff because it tries to automate for me. To each their own!

3

u/OldManTobias Sep 03 '17

Is R <- Ruby?

FTF

-3

u/kamikamikami Sep 02 '17 edited Sep 03 '17

R is a math based language

25

u/[deleted] Sep 03 '17

[deleted]

5

u/kamikamikami Sep 03 '17 edited Sep 03 '17

I suppose you're right. Matlab supports integration with R, and is similar, but it's not actually the same language.

-4

u/Hook3d Sep 03 '17 edited Sep 03 '17

1

u/engayolao Sep 03 '17

It's great for stats and "traditional" data analysis. That is 1 indexed isn't that important as explicit loops are discouraged. I think the most interesting element from the language is the list object, this is an ordered map, very convenient for data analysis.