👩💻 Join our community of thousands of amazing developers!

Karl Broman was surprised that x[[c(5, 3)]] in R was the same as x[[5]][[3]]. And it was in 2013. It reminded me of a similar thing that surprised me a couple of months ago. I have used R for more than 10 years, and for the first time I had discovered that for a matrix x and a two-column integer index matrix i (each row of i is a pair of row and column indices to index x), x[i] returns the vector c(x[i[1, 1], i[1, 2]], x[i[2, 1], i[2, 2]], ..., x[i[n, 1], i[n, 2]]). Actually I had been searching...