[19082] in s-news-athena
RE: [S] Putting values into matrices: desired behaviour?
daemon@ATHENA.MIT.EDU (Gunter, Bert)
Wed Sep 1 08:53:27 1999
Message-Id: <199909011249.HAA21706@wubios.wustl.edu>
Date: Wed, 01 Sep 1999 08:49:10 -0400
From: "Gunter, Bert" <bert_gunter@merck.com>
To: "'Mette.Langaas@nr.no'" <Mette.Langaas@nr.no>,
"'s-news'" <s-news@wubios.wustl.edu>
Mime-Version: 1.0
Content-Type: text/plain
Content-Transfer-Encoding: 7BIT
Mette:
Thankyou for your Splus posting. I have been using SPlus for several years
and never noticed this. I fooled around with it on the basis of your
posting, and it looks like a problem to me. Note that in your example,
>test[3,2]
Error in test[3, 1]: Array subscript (3) out of bounds, should be at most 2
does give the desired error message, so apparently it is not checking
properly for out of bounds subscripts when a matrix subscript is given.
Unless there is some subtlety that I'm missing, in which case I would
greatly appreciate a public rebuke. Would S-Plus please confirm or explain
this?
-- Bert Gunter
---- Original Message -----
> S-Plus users and experts,
>
> I'm running S-Plus 5.1 on UNIX (but the same behaviour I'm describing is
> seen on S-Plus 3.4 R1 for UNIX).
>
> I have first created a matrix with two rows and three columns
>
> > test_matrix(ncol=3,nrow=2)
> > test
> [,1] [,2] [,3]
> [1,] NA NA NA
> [2,] NA NA NA
>
> I then want to put values into parts of the matrix, but by mistake I
> index outside the matrix (use rows 3-7 when there are only 2 rows).
>
> > ind_matrix(c(1,2,3,4,5,6,7,2,2,2,2,2,2,2),ncol=2)
> > ind
> [,1] [,2]
> [1,] 1 2
> [2,] 2 2
> [3,] 3 2
> [4,] 4 2
> [5,] 5 2
> [6,] 6 2
> [7,] 7 2
> > test[ind]_c(3,4,5,6,7,8,9)
> > test
> [,1] [,2] [,3]
> [1,] NA 3 5
> [2,] NA 4 6
>
<... SNIP ....>
> Best regards
> Mette Langaas
> Norwegian Computing Center
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news