[R] terminate R program when trying to access out-of-bounds array element?

From: Vivek Rao <rvivekrao_at_yahoo.com>
Date: Thu 14 Apr 2005 - 07:26:12 EST


I want R to stop running a script (after printing an error message) when an array subscript larger than the length of the array is used, for example

x = c(1)
print(x[2])

rather than printing NA, since trying to access such an element may indicate an error in my program. Is there a way to get this behavior in R? Explicit testing with the is.na() function everywhere does not seem like a good solution. Thanks.



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Apr 14 07:31:28 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:08 EST