From henrik.bengtsson at ucsf.edu  Sat May  9 22:33:46 2015
From: henrik.bengtsson at ucsf.edu (Henrik Bengtsson)
Date: Sat, 9 May 2015 13:33:46 -0700
Subject: [Rd] R Language Definition: Subsetting matrices with negative
 indices is *not* an error
In-Reply-To: <FFEC09E0-0FF0-48F0-8238-4FD01E5E6A6E@gmail.com>
References: <CAFDcVCQdx0XQaBgw8rNrN0ayB8fxbiFPanXRPgfwys93zpBG8A@mail.gmail.com>
	<FFEC09E0-0FF0-48F0-8238-4FD01E5E6A6E@gmail.com>
Message-ID: <CAFDcVCTPxo3gPoH8KOZOkH45xxAisLNeLmkw3-Ejf89Be0z9PQ@mail.gmail.com>

On Sat, May 9, 2015 at 12:55 AM, peter dalgaard <pdalgd at gmail.com> wrote:
>
>> On 09 May 2015, at 02:53 , Henrik Bengtsson <henrik.bengtsson at ucsf.edu> wrote:
>>
>> Hi,
>>
>> I spotted what looks like another(*) mistake in 'R Language
>> Definition' on how subsetting should work.  In Section 'Indexing
>> matrices and arrays'
>> [http://cran.r-project.org/doc/manuals/r-release/R-lang.html#Indexing-matrices-and-arrays]
>> one can read
>>
>>   "Negative indices are not allowed in indexing matrices."
>
> Parse error: I believe that this is intended to mean
>
> "Indexing matrices may not contain negative indices"
>
> not
>
> "You cannot use negative indices when indexing matrices".
>
> This is consistent with the help page:
>
> "
>      A third form of indexing is via a numeric matrix with the one
>      column for each dimension: each row of the index matrix then
>      selects a single element of the array, and the result is a vector.
>      Negative indices are not allowed in the index matrix.
> "
>
> Rephrasing would seem to be in order....

Ah... definitely a "parse error" (I read it as a new paragraph).  I
second rephrasing this; your ""Indexing matrices may not contain
negative indices" is non-ambiguous.

Thanks Peter

/Henrik

>
> -pd
>
>>
>> but this is not true, e.g.
>>
>>> x <- matrix(1:12, nrow=4)
>>> x
>>     [,1] [,2] [,3]
>> [1,]    1    5    9
>> [2,]    2    6   10
>> [3,]    3    7   11
>> [4,]    4    8   12
>>
>>> x[c(-2,-4),]
>>     [,1] [,2] [,3]
>> [1,]    1    5    9
>> [2,]    3    7   11
>>
>> /Henrik
>>
>> (*) https://stat.ethz.ch/pipermail/r-devel/2015-May/071091.html [docs
>> have been fixed]
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>
> --
> Peter Dalgaard, Professor,
> Center for Statistics, Copenhagen Business School
> Solbjerg Plads 3, 2000 Frederiksberg, Denmark
> Phone: (+45)38153501
> Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com
>
>
>
>
>
>
>
>



[Rd] R Language Definition: Subsetting matrices with negative indices is *not* an error
Henrik Bengtsson