News for hackers. Stuff that matters.
Re:A Quick Introduction to R by sva_ on Sunday February 06, 2022 @09:49AM (#30232956)
My least favorite thing so far was indices starting at 1. It seems blasphemous, in a way.

On a more serious note, I agree that R being too charitable in interpreting things (seemingly without warning) seems to be a problem. You'll have to do some debugging to make sure it actually does what you intended it to do. I've only dabbled in it a bit though.

Re:A Quick Introduction to R by kergonath on Sunday February 06, 2022 @11:24AM (#30233947)
> My least favorite thing so far was indices starting at 1. It seems blasphemous, in a way.

In the real world we start counting from 1. CS people cannot stop complaining about it but it makes sense in languages used for mathematics and statistics. Zero-indexing is not very relevant if you don’t care about memory layout.

Re:A Quick Introduction to R by sva_ on Sunday February 06, 2022 @04:11PM (#30237035)
I know plenty of mathematicians who insist 0 ∈ ℕ. It's a bit of a joke, like arguing over tabs vs. spaces though.

May I recommend you this fabulous short essay by Dijkstra: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...

It has nothing to do with memory layouts.

Re:A Quick Introduction to R by kergonath on Sunday February 06, 2022 @08:07PM (#30238889)
> It's a bit of a joke, like arguing over tabs vs. spaces though.

It is taken very seriously, though. This “issue” comes up very often when some people come and lecture others about how stupid the language they use is.

> May I recommend you this fabulous short essay by Dijkstra

That essay is not fabulous, it is obnoxious. I know you either love or hate Dijkstra and he enjoyed being a contrarian, but he’s unconvincing. The only point that surfaces during arguments on 0-indexing is iterating over 1..N-1 instead of 0..N. That’s basically what he wrote himself. This could have been solved with just a bit of syntax if it were really a problem, and it remains largely because C did it that way to simplify pointer arithmetics. It does not change the fact that for the vast majority of people, the first element in a list is, well, first.

The proper way of handling this is to allow for arbitrary indices, because you will always find contexts where a different scheme makes sense (e.g. iterating from -10 to 10 is sometimes natural, and would otherwise require some index gymnastics). Insisting that one narrow view is the correct one is just annoying.

Re:A Quick Introduction to R by sva_ on Sunday February 06, 2022 @11:06PM (#30240276)
I dunno, it seems you misunderstood me, or idk. I clearly said that it is completely arbitrary to choose one over another, and expressing a preference over either one is just a way of poking fun at people who are anal about choosing a specific one. So there isn't really any disagreement, though I'm always amazed at what lengths people go to, to express what they think, while they're really just arguing about the definition of some thing.

> It is taken very seriously, though.

And those who do take it terribly seriously deserve being poked at ;)

Re:A Quick Introduction to R by CornCobs on Sunday February 06, 2022 @11:14AM (#30233840)
Honestly indices starting from 1 fits really nicely in most situations. 1-based indexing together with ranges and inclusive range-based indexing makes loops and subsetting code really readable IMO
Re:A Quick Introduction to R by hashimotonomora on Sunday February 06, 2022 @10:38AM (#30233439)
It’s pretty standard in math software such as Matlab and Octave.
Re:A Quick Introduction to R by ProjectArcturis on Sunday February 06, 2022 @12:07PM (#30234403)
That's my favorite thing for R relative to Python. Far more intuitive to start at 1 rather than 0.
Re:A Quick Introduction to R by ekianjo on Sunday February 06, 2022 @10:33AM (#30233378)
> It seems blasphemous, in a way.

It's more natural. You never count from zero with real life objects.

Re:A Quick Introduction to R by Mikeb85 on Sunday February 06, 2022 @11:00AM (#30233683)
It's standard because indexes start at 1 in Fortran. Not sure why it's an issue, especially because you never need to use loops in R anyway.
Re:A Quick Introduction to R by epgui on Sunday February 06, 2022 @03:17PM (#30236558)
Many languages are like that. I learned recently that indices also start at 1 in PostgreSQL / PLpgSQL.