Live data from Hacker News

One Year with R

github.com

181–190 of 266 posts

Re: One Year with R

#181
post #52

Earlier quoted context omitted.

I've used R for 19 years and do not have any other programming language ability. I am curious: What is frustrating to you about R relative to other languages?

I'm not OP. To me, it's the tooling around it. Everything is done in R-studio and it's focus is to generate statistical documents. The result is a sub optimum solution. It lacks good tooling around installing and running R programs. R programs don't import, they include. It doesn't make it more readable. R-studio is very Emacs like in the sense that it just lacks a decent editor. Due to R-studio being the default, th…

I use Vim with the R command line wrapped around Makefiles. I don't even have RStudio installed. Works great.

I can even pop up an interactive R command prompt session and do whatever I want in it, even quick ggplot2 graphs. Help shows up just as you would expect, and plots pop up in new windows. RStudio is much less advanced than people think it is, it's really just managing R's windows for you and doing generic IDE work. R is doing all the heavy lifting.

If you're wanting a more "import" like thing you might want to look into making R packages instead of scripts. You don't have to submit them to CRAN, and you can execute them pretty simply on the R command line as well.

That being said, it's really not an OOP or software development tool. It's definitely geared toward data science, but you can automate that very well for generating graphs automatically and reporting for whatever reason needed.

Re: One Year with R

#182

Earlier quoted context omitted.

> Before R commercial statistical packages were mainly used. Maybe in your field, I work in bioinformatics - before R, perl was widely used as a high-level language. > Regarding keeping versions straight, all past versions of packages in the CRAN repository are kept on CRAN... This is woefully inadequate if you need to replicate somebody else's environment. Nobody should think manually guessing and then typing in eac…

The packages that were used in statistics were SAS, SPSS and Stata. perl is not a statistical package and has nowhere near the depth of statistical capabilities of R. Don't forget that I also mentioned the checkpoint package in my post. You only need to know the date for that, not the version of each of the packages. In your last paragraph I think you are referring more to software development practices than what is…

That's a very roundabout way to solve an actual problem. In many cases you don't pin your package version to _latest_ (whatever that date is) and you need a more fine-grained solution to keeping package versions. I don't think that solves this and I don't know if you can do it with checkpoint.

Re: One Year with R

#183
post #155

R is a truly terrible language with a handful of bright spots, such as it's visualization libraries. The boost you get from the slightly better expressiveness of R over something like Julia or Python is not worth the headaches you'll run into down the road in trying to maintain whatever you wrote 6 months later, or God forbid, trying to integrate your code into someone else's work. R was my first language and in hind…

Counterpoint: a lot of work in R is not "development" in the ordinary sense. The outcome is not a piece of maintainable code that needs to be built on later or be generally useful in any way other than copying an occasional snippet.

In some research fields (e.g. scientific fields that use R) the ground rules are that the code needs to be understandable and it needs to be clear that the libraries involved were used correctly. That's basically it. Even hardcoded directories are common. Good development practices are not widely understood to be important and in general many people are just starting to get the hang of version control and might not use it at all.

If R enables you to solve a statistical problem you have right now and it does this in a way that is better or more comprehensible for the people who use it, that means it has a niche. As someone with software development experience in a bunch of other languages, I agree with you that R is full of weird warts, but let's not forget that there are areas where its value is still obvious.

Citation: my partner works in a scientific field where R is predominant.

Re: One Year with R

#184
Personally, I feel like the biggest problems with Python for math is the lack of a native vector datatype and our subsequent reliance on Numpy which really disrupts the elegance/terseness of working with vectors/matrices.

First, there's the constant inelegance/clutter/inefficiency of having to cast into and out of arrays and lists, even when doing basic list comprehension. R, Julia, and Matlab are all vector-based languages (I think), so you avoid having this casting as much.

Secondly, having a native vector type means you don't have to worry about the performance penalty of operating directly on arrays if an existing prebuilt method exists. Since the efficiency of Numpy comes from calling it's underlying C library, you're forced to memorize and use prebuilt Numpy functions rather then just use the more obvious and elegant array manipulations. For example rather than calculating the the cumulative sum like this:

  cumsum = reduce(lambda a, b: a+b, [1,2,3,4]) 

 We have do this: 

  cumsum = np.cumsum([1,2,3,4])
(There are better examples, but this is all I can think of right now).

And once you add something like Pytorch tensors on top of this, we now have an additionally layer of casting/redunduncy/memorization of prebuilt functions!

Re: One Year with R

#185

Earlier quoted context omitted.

Coming from Matlab, I have the opposite feeling. I truly, genuinely dislike the language. I think it's very productive, and I appreciate that Matlab costs an arm and a leg (and god help you once you start paying for some of the nicer packages on top) - but Matlab has spoiled me immensely on the language front. To me, Matlab feels like a language that was designed with an intent to appeal to folks with some understand…

> R feels like a language that was built for people who were using excel, I don't think so. Most people who come to R after years of Excel find it just as alien as you do.

I recall when the pipe operator was first being proposed the argument for it was that it'd enable workflows that felt more like Excel. The implication being that indeed, base R is alien to an Excel user.

I also recall my pushback was along the lines of "who on earth would want that". Yeah, it's a good thing I'm not the person coming up with these things :)

Re: One Year with R

#186
post #46

Earlier quoted context omitted.

> how use of R is more complex when you’re largely ignorant of the tidyverse This. I'm interested in non-flamewar non-religious reasons that the tidyverse is bad. He does give some. I think his complaints about inconsistency and a moving target have some validity. However, the price of not using tidyverse is (roughly) paid in the rest of the article. I would definitely not use R without it. Read his Section 5 on the…

> I'm interested in non-flamewar non-religious reasons that the tidyverse is bad. Going to answer with a question: Why is tidyverse == R considered true? I use ggplot frequently, but for data manipulation data.table is orders of magnitude more powerful. And more stable.

Tidyverse is so much more verbose than data.table, it’s painful. I don’t see the draw to it, to be honest.

Re: One Year with R

#187
post #155

R is a truly terrible language with a handful of bright spots, such as it's visualization libraries. The boost you get from the slightly better expressiveness of R over something like Julia or Python is not worth the headaches you'll run into down the road in trying to maintain whatever you wrote 6 months later, or God forbid, trying to integrate your code into someone else's work. R was my first language and in hind…

Counterpoint: a lot of work in R is not "development" in the ordinary sense. The outcome is not a piece of maintainable code that needs to be built on later or be generally useful in any way other than copying an occasional snippet. In some research fields (e.g. scientific fields that use R) the ground rules are that the code needs to be understandable and it needs to be clear that the libraries involved were used co…

> I agree with you that R is full of weird warts, but let's not forget that there are areas where its value is still obvious.

For sure. As much frustration as I had with R, at the time it was an enormous improvement over the stuff that came before it. And its emergence and success led to other languages improving their data and analytics capabilities.

Re: One Year with R

#188
I am surprised no one has mentioned the awful [garbage collector](https://stackoverflow.com/q/14580233/850781).

The R garbage collector is imperfect in the following (not so) subtle way: it does not move objects (i.e., it does not compact memory) because of the way it interacts with C libraries. (Some other languages/implementations suffer from this too, but others, despite also having to interact with C, manage to have a compacting generational GC which does not suffer from this problem).

Re: One Year with R

#189
post #45

Earlier quoted context omitted.

I'm going to side with the author here: if he read "Advanced R", "R for data Science", "The R Inferno", "Rtips. Revival 2014!", the official "An Introduction to R", "R Language Definition", and "R FAQ", and yet he still has problems with the language , then maybe the language is to blame. And even if the author is the problem, I wouldn't accuse them of not reading enough.

Ok, but if someone claims to have read all the Python manuals and wrote something like > Python has two types of empty string, array('u',) and "" you'd probably conclude that hasn't really understood what he read.

For Python (at least Python3) a better example might have been b"" and "". They are not equal, and they are empty. You have to decode or encode one, for instance, and different functions return different things. Then different functions might return False, None, (), {}, etc.

This OP complaint seems like weird nitpicking about R. Many languages have different empty/null-types for different variable-types. Also, don't get me started on "nulls" in C, C-strings, C++ strings, or memory allocation.

All languages are complicated.

Re: One Year with R

#190
post #162
post #128

Earlier quoted context omitted.

This is just a quick example - I would be grateful if people could recreate this brief look at UK COVID figures in another language: library(tidyverse) library(scales) download.file(url = "https://api.coronavirus.data.gov.uk/v2/data?areaType=overview&metric=covidOccupiedMVBeds&metric=newAdmissions&metric=newCasesBySpecimenDate&metric=newDeaths28DaysByDeathDate&metric=newPeopleReceivingFirstDose&format=csv", destfile…

import pandas as pd import matplotlib.pyplot as plt import matplotlib.dates as mdates import seaborn as sn df = (pd.read_csv("/tmp/overview_2022-03-21.csv") # i just used curl beforehand .assign(date=lambda x: pd.to_datetime(x["date"])) .set_index("date") .melt(value_vars=[ "newCasesBySpecimenDate", "covidOccupiedMVBeds", "newAdmissions", "newDeaths28DaysByDeathDate"], var_name="Data", ignore_index=False) .assign(Dat…

> I hate all the python plotting libraries.

I've given up discussing this. My personal opinion is that MPL is the assembly vs ggplots2's Python.

Yes, maybe there are some things that are doable in MPL but not in ggplot2, but never (and I mean - never -) has any one of my colleagues found a single example that I couldnt recreate in ggplot2 with a more readable code that resulted in a better looking plot.

MPL has this Latex like "once you get the hang of it, you will never use anything else in life for anything" and OOP's "If its good code then it is OOP and if its not, then you're not doing correct OOP" mythisque hanging over it. When confronted with bad MPL code that results in bad plots, its always one of those two.

ggplot2 is the best plotting package out there and imo one of the best "end-user" packages in any language. Also, Hadley is a saint.

Post reply on HN