Peter Dalgaard BSA writes:
The explanation seems to be in different behaviour of the
substitute(...) construction:
f<-function(a,b){a<-1; print(deparse(substitute(c(a,b))))}
f(a,b)
f<-function(a,b){a<-1; print(deparse(substitute(c(a,b))))}
f(a,b)
[1] "c(a, b)"
[1] "c(a, b)"
So in R, assignment to a formal parameter causes the changed value to
be used for substitution purposes.
In S, this does not happen *unless the formal parameter is a
constant.*!
[1] "c(1, b)"
[1] "c(1, b)"
[1] "c(2:2, b)"
[1] "c(2:2, b)"
[1] "c(1, b)"
[1] "c(1, b)"
This is confusing in both languages, but I'd say that S has the bigger
problem...