On Thu, 3 Nov 2016, Berend Hasselman wrote:
Try this in R:
A <- matrix(1:12,nrow=3)
A
A[-1,-2]
displays A without first row and second column.
As I expected and hoped.
OK, if there's a precedent out there, and if people feel that these
semantics are more useful than negative indices meaning "count from
the end", I withdraw my objection.
I've made start on implementation. Supported so far: a single negative
index per dimension, as in Berend's example, and also an all-negative
index-vector per dimension. An exclusion in one dimension can be
combined with an arbitrary "positive" specification in the other.
<hansl>
matrix A = mshape(seq(1,12), 3, 4)
A
eval A[-1,-2]
eval A[1:2,-2]
eval A[{1,3},-2]
eval A[,{-1,-3}]
eval A[2:3,{-1,-3}]
eval A[2:3,seq(-1,-3)]
</hansl>
(As in Jack's follow-up posting, you can't mix positive and negative
values in a single index-vector.)
Not sure about exclusionary "from:to" ranges. The R syntax is
"-(from:to)". Supporting that would require additional changes to the
parser. Maybe just tell people to use seq() for this?
Allin