[R] Variables of a function called inside another one

JSHuang js.huang at protective.com
Fri Jan 30 02:34:06 CET 2015


Hi,

  Maybe I missed something.  The following example works.  It should not
cause any problem with the same parameter names since their scopes are
within the functions.

> function2 <- function(a,b,c,d){
+ a+b+c+d}
> function2(1:2,2:3,3:4,4:5)
[1] 10 14
> function1 <- function(a,b,c,d){
+ newb <- b+1
+ newc <- c+1
+ newd <- d+1
+ function2(a,newb,newc,newd)}
> function1(1:2,2:3,3:4,4:5)
[1] 13 17



--
View this message in context: http://r.789695.n4.nabble.com/Variables-of-a-function-called-inside-another-one-tp4702469p4702493.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list