quick programming question.  I am not making enough errors in my
programs, so I want to trigger a few more.  ;-)

[1] undefined variable behavior:

> d=data.frame( x=rnorm(1:10), y=rnorm(1:10))
> z
Error: object 'z' not found
> d$z
NULL

is this consistent?  I thought that z is the same as .GlobalEnv$z, but
apparently it is not.  something here is smart enough to trigger an
error.   I like this error behavior.   is it possible to set an R
global option that triggers the same 'not found' error when an
undefined element of a list or data frame is accessed?

[just trying to check all my function arguments, and right now, I
think I need to include for each argument
'stopifnot(is.null(argument))'.  This clutters the code.]


[2] is it possible to turn off recycling for vector operations?  (I
may have asked this at some point already, but I can't find the
answer.)

> a=c(2,3)
> b=c(4,5,6,7)
> a+b
[1]  6  8  8 10

when I really want recycling, I would rather do it explicitly with rep.


regards,

/iaw
----
Ivo Welch (ivo.we...@brown.edu, ivo.we...@gmail.com)

______________________________________________
R-help@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.

Reply via email to