- Conclusion
There are two conclusions for this page.
- R uses "Pass by value".
- R uses "Default initialize".
- Function 1
First, create an R code file "func_1.r" contains this,
run it and trace the result to see the difference.
```
# File name: func_1.r
hello <- function(input){
a <- c("Hello", "world", input, "!")
input <- NULL
molas <- "molas"
ret <- paste(a, collapse = " ")
ret
}
molas <- "MOLAS"
input <- c("again,", molas)
input
hello(input)
molas
input
hello()
hello(NULL)
```
- Function 2
First, create an R code file "func_2.r" contains this,
run it and trace the result to see the difference.
```
# File name: func_2.r
hello <- function(a, ...){
ret <- paste(a, ...)
ret
}
test <- function(input = "molas") {
a <- c("Hello", "world", input, "!")
input <- NULL
molas <- "molas"
ret <- hello(a, collapse = " ")
ret
}
molas <- "MOLAS"
input <- c("again,", molas)
input
test(input)
molas
input
test()
test(NULL)
```
---