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

Vivek Rao rvivekrao at yahoo.com
Wed Apr 13 23:26:12 CEST 2005


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.




More information about the R-help mailing list