5 ms·
Other things: 1. Unmatched simplicity of dplyr for data manipulation. 2. Great graphs with ggplot2. Oh, and 1-based indexing. Try telling economics students
by dash2 3y ago
Other things:
1. Unmatched simplicity of dplyr for data manipulation.
2. Great graphs with ggplot2.
Oh, and 1-based indexing. Try telling economics students why 3..5 means elements 4 and 5.
- jraph 3y ago(edit: we are actually agreeing, see replies) Doesn't 3..5 mean elements 3 and 4 : the 3rd and the 4th? 0-based indexing might feel less intuitive actually (element 3 is the 4th, and element 4 is the 5th). I don't know much R, I'm assuming that in the n..m notation, n is included and m is excluded (edit: also included, see replies). I don't now about economy, but I think mathematicians use 0-indexed and 1-indexed sequences interchangeably and they usually (have to) specify which is the first term (u0 or u1).
- williamdclt 3y ago> Doesn't 3..5 mean elements 3 and 4 : the 3rd and the 4th? 0-based indexing might feel less intuitive actually Yes, you’re agreeing! The point of the parent was that 0-indexing is less easy to grasp
- jraph 3y agoOh, right! I parsed the last sentence in a weird way I guess. Also thanks rcthompson for the precision about intervals being inclusive on both ends in R.
- dash2 3y agoOrdinary humans count from 1.
- rcthompson 3y agoR's indexing is not only 1-based, it's inclusive on both ends. So indexing from 3 to 5 actually gets you elements 3, 4, and 5. I've programmed a bunch with both R and 0-based languages and I greatly prefer R's way of doing indexing.
- trealira 3y agoI'm pretty sure it's like this in Pascal, too. Which makes sense, since it's the only way to reasonably index 1-based arrays. For example, you'd expect the following code to set arr to the set "1, 2, 3, 4, 5", not to leave the last element uninitialized. var arr: array [1 .. 5] of integer; begin for i := 1 to 5 do arr[i] := i end; Normally you would write "for i := low(arr) to high(arr)". I just wrote the numbers "1 to 5" to be explicit here.