Live data from Hacker News

Learn R Through Examples (2020)

gexijin.github.io

61–68 of 68 posts

Re: Learn R Through Examples (2020)

#61
I work using R almost everyday and I think many of the problems that are unique to R could be solved by having a couple of experienced SWE in the core team to point R in the right direction. As it stands, I think R will be left behind until it fixes things like performance and scalability (e.g. intuitive byref semantics and a faster runtime) and a consistent scoping model and OOP.

Apart from that, I think there's a bigger challenge which still needs to be addressed is that analysis/modelling projects tend to be worked on by individuals and/or thrown away after the initial value is pulled out of them.

Going forward, I think we need to start identifying design methodologies that would make collaborating on this sort of work pain-free and more agile. Doing so should give us more value and sooner and for longer.

Re: Learn R Through Examples (2020)

#62
post #41

Lot's of negative comments in here about learning R from experienced programmers. I've found this is largely because experienced programmers have this unjustified bias that R is some toy language that should be easy to learn and has nothing to teach them. If you approached a language like Rust in the same way you would likely be just as frustrated with it. Certainly R has its quirks, but most of this comes from being…

What is the advantage of "thinking in vectors" in R versus "thinking in vectors" using numpy in Python (for example)?

There’s some overlap, but vectors are essential to the language. Every type of data in R is a vector. There are no scalars, just vectors of length 1. Instead of dictionaries, it’s idiomatic in R to use “lists”, which are vectors of vectors. Data frames are lists (vectors of vectors) constrained to have equal length element vectors (ie columns). Classes are defined as lists with some metadata (stored in a vector) to direct method dispatch.

It’s not just vectorizing mathematical operations a la numpy.

Re: Learn R Through Examples (2020)

#63

Earlier quoted context omitted.

I was quite surprised how easy that book was to read and understand. I’d expected “advanced” any language to be much more difficult.

The title is kind of misleading - the book is more of a list of exceptions, edge cases, unexpected behaviour and other gotchas.

That is not an accurate description of the book.

Re: Learn R Through Examples (2020)

#64
post #8

Earlier quoted context omitted.

I pretty much had the same experience with R. I've never been able to get really productive with it as a software developer. I feel like I know too much and can't break from old habbits. It's very academic which I feel really holds it back from software devs and also captures non developers in it's web. Whilst it's certainly got some runs on the board. I think having data science folk work in more standard languages…

Funny, I'll never say that R itself is very academic. The environment maybe, the users sure but the language is very much an mutated Lisp with vectorized operation. Same for the python stuff, I never hit that problem working a lot with it but most of the time when I wanted to check a lib, I landed in C++ aka I am not sure to understand how to read the code. What in R made it feel academic for you?

For one, R has a built in citation() function.

Secondly, it seems optimised for producing one off figures and results, not production systems generally desired by industry.

Re: Learn R Through Examples (2020)

#65
post #50

R plus the tidyverse is what makes it a great language. Some tidyverse concepts are being baked into base R, like the pipe, but base R by itself feels hollow. R’s future is inseparable from the tidyverse. We need to just lump them together in any serious discussion of R. I teach a graduate level R course mainly for economics and statistics majors. (My educational background and career are computer science and technic…

Just for the record, many users are happy with base R. There are dozens of us! R by itself is nice. But the tidyverse is creeping in and bringing dependency hell with it. http://www.tinyverse.org/

hard second. ggplot2 was the last (only) good package hadley ever wrote; the rest is more about reinventing the wheel and viral-marketing with hex-stickers than about getting work done. the newer stuff in particular is atrocious; heaven forfend function calls that don't require understanding the lore of a package (`recipes` has stupid functions like `recipe`, `bake` and similar nonsense).

at a push, base + data.table + ggplot2 get everything done. tinyverse ftw.

Re: Learn R Through Examples (2020)

#66
Coming from writing OOP-style code in Python and C++, I initially disliked R quite a lot. My code is becoming more functional-style by the year and I'm now finding myself enjoying R more and more.

There are issues with R: lots of weird quirks; many different ways of doing things, often just supported for legacy reasons; poor error messages; to name just a few. But on the positive side, it really encourages functional-style programming through the use of apply functions and many of the new tidyverse packages. The resulting code can be very neat and less error-prone than equivalent python code.

The S3 system of OOP initially struck me as very weird, but now I see it as essentially just single dispatch, not really much of OOP at all. It works quite well and is extremely simple.

I guess my thoughts are: approach R as a functional language, and I think you'll find much to like. Try to write C++ or python-style OOP in it, and you'll just find it very strange.

Re: Learn R Through Examples (2020)

#67
post #37

Lot's of negative comments in here about learning R from experienced programmers. I've found this is largely because experienced programmers have this unjustified bias that R is some toy language that should be easy to learn and has nothing to teach them. If you approached a language like Rust in the same way you would likely be just as frustrated with it. Certainly R has its quirks, but most of this comes from being…

I have used R a few times now, and I definitely agree with the statement that thinking in vectors is central to writing good R scripts. However, as a computer engineer and performance junkie, its unfortunate that it doesn't get as much attention as other "STEM DSLs" (Julia, MATLAB) when it comes to performance. The same could technically be argued for Python; The current approaches to dealing with high-performance co…

There are few comments here complaining about R performance just like the parent comment. It's a shame that R does not have industrial strength industrial compiler based on this blog article unlike Python [1].

If you want to see the performance benchmark of R against major programming languages for data analysis please check this excellent keynote speech on the R compilation or more accurately on failures of R compilation effort [2].

As mentioned in [1], the main reason people do not focus on providing industrial strength compiler for R is probably because most of R program’s time are spent in the library codes that are written in a compiled language (e.g., C or Fortran). As you can see from [2], even though this is the case (computation intensive being delegated to proper compiled languages), the R programs running time still suffers due to the "impedance mismatch" because of the look up overheads, indirections, etc.

Perhaps someone should try to compile, transpile and/or embed R inside D language similar to the efforts provided in [3][4]. D now supports C compiler internally, has DasBetterC and D interface to C++ (DPP) is second to none. Additionally, since D can also perform better than Fortran codes for numerical computing perhaps Fortran codes can eventually be replaced by existing high performance D library like Mir[5]. I can foresee this symbiotic relationship can be beneficial for R and D (R on D?). D can becomes very popular with extra humongous data analysis and statistics libraries from CRAN, and R can get the run time and compilation performance improvement it badly needs.

[1]https://www.r-bloggers.com/2021/05/where-are-the-industrial-...

[2]https://www.youtube.com/watch?v=VdD0nHbcyk4

[3]https://dlang.org/blog/2018/06/20/how-an-engineering-company...

[4]https://theartofmachinery.com/2021/01/01/djinn.html

[5]http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/...

Re: Learn R Through Examples (2020)

#68
post #28

I currently do lots of data analysis in excel and know basic Python. I would be interested to get opinions on if R is better suited to data analysis than python if that’s all I was doing.

Python is certainly more popular and for job prospects I always tell that to newer data folks. That being said if you want to load in some data do some SQL like manipulation, run some stats and make a graph or output a report I would argue R is way better experience than Python but that’s much more about the package ecosystem and less a comment on the language. Dplyr is just more friendly to use than pandas (often 3-…

These days I usually prefer to use sqldf. It's so powerful how it let's you reference existing dataframes within the SQL command. It's like spark.sql in Python and temporary views but much more simple.
Post reply on HN