Tamas K Papp
2007-Feb-28 02:15 UTC
[Rd] asking for advice on how to catch nonexistent list elements
Hi, I am sorry if this is documented or in the archives somewhere, I tried searching and could not find anything. When using the $ operator to get a nonexistent element (or if you prefer, all elements are defined as NULL by default) of a list, it returns NULL, eg> a <- list(maximum=12) > a$maximum[1] 12> a$maxium # typoNULL I know that this is the documented behavior of $, so this is definitely not a bug. But it leads to bugs that are quite elusive: an error will only be generated when some function eventually chokes on NULL. I would like to know how people cope with that, and if there is a way to generate an error message (at least when debugging code) for the typo above. Thanks, Tamas