-6

if i create a function in R, for example:

f<-function(x){
x
.....

}

when execute function R use pass-by-value or pass-by-reference

1 Answers1

-1
In R it is call by value. To prove this i tried with a small function as below;

f1 <- function(a,b){

  print(a)

  #print b value before call
  print(b)

  fi(b)
  #print b value after call
  print(b)

}

fi <- function(i){
   i = i + 20
}

f1(10,20)

output :
----------
[1] 10
[1] 20
[1] 20