[R] Error: subscript out of bounds.
Patrick Burns
pburns at pburns.seanet.com
Tue Sep 23 11:05:09 CEST 2008
There is a good reason for the error in the
matrix case. Consider what would need to
happen for:
m[3, 5] <- 100
to work.
Consistency might be a good thing here, but
if so I think it should be an error for the 1-D
case. This might be a useful difference between
1-D arrays and vectors. However, it isn't clear
(to me at least) what such a change would break.
Patrick Burns
patrick at burns-stat.com
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")
Rolf Turner wrote:
>
> Consider:
>
> > x <- array(1:12,dim=12)
> > x[13]
> [1] NA]
> > m <- array(1:12,dim=c(3,4))
> > m[3,5]
> Error: subscript out of bounds
>
> Can anyone tell me it there is a Good Reason for the difference in
> behaviour
> between 1 dimensional and higher dimensional arrays? In a bit of code
> that
> I was working on I expected the NA behaviour and didn't get it of
> course. Then
> I had to take evasive action to avoid the error.
>
> Naive young thing that I am, I would prefer the NA behaviour to be
> universal.
> But I expect that, as usual, I'm overlooking something.
>
> cheers,
>
> Rolf Turner
>
> ######################################################################
> Attention:\ This e-mail message is privileged and confid...{{dropped:9}}
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>
More information about the R-help
mailing list