R and NumPy Slicing Reference

Switching back and forth from R to NumPy, I sometimes forget how the arrays for each are indexed. This is just a note to myself for future reference.

NumPy:
[0:3] Rows 0-2, all columns
[:,0:3] All rows, columns 0-2

R:
[1:3,] Rows 1-3, all columns
[,1:3] All rows, columns 1-3

Leave a Reply

Your email address will not be published. Required fields are marked *