R Language Definition: Subsetting matrices with negative indices is *not* an error

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

R Language Definition: Subsetting matrices with negative indices is *not* an error

Henrik Bengtsson-4
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."

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]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R Language Definition: Subsetting matrices with negative indices is *not* an error

Peter Dalgaard-2

> On 09 May 2015, at 02:53 , Henrik Bengtsson <[hidden email]> 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....

-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]
>
> ______________________________________________
> [hidden email] 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: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R Language Definition: Subsetting matrices with negative indices is *not* an error

Henrik Bengtsson-4
On Sat, May 9, 2015 at 12:55 AM, peter dalgaard <[hidden email]> wrote:

>
>> On 09 May 2015, at 02:53 , Henrik Bengtsson <[hidden email]> 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]
>>
>> ______________________________________________
>> [hidden email] 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: [hidden email]  Priv: [hidden email]
>
>
>
>
>
>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R Language Definition: Subsetting matrices with negative indices is *not* an error

Bert Gunter
Ah, the woes of English word order -- even this native English speaker
frequently gets messed up!

(but maybe I'm just a bear of little brain).

Best,
Bert

Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
Clifford Stoll




On Sat, May 9, 2015 at 1:33 PM, Henrik Bengtsson
<[hidden email]> wrote:

> On Sat, May 9, 2015 at 12:55 AM, peter dalgaard <[hidden email]> wrote:
>>
>>> On 09 May 2015, at 02:53 , Henrik Bengtsson <[hidden email]> 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]
>>>
>>> ______________________________________________
>>> [hidden email] 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: [hidden email]  Priv: [hidden email]
>>
>>
>>
>>
>>
>>
>>
>>
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: R Language Definition: Subsetting matrices with negative indices is *not* an error

Peter Dalgaard-2
In reply to this post by Henrik Bengtsson-4

> On 09 May 2015, at 22:33 , Henrik Bengtsson <[hidden email]> wrote:
>
> On Sat, May 9, 2015 at 12:55 AM, peter dalgaard <[hidden email]> wrote:
>>
>>
>> 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.

Now in R-devel.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel