Functions and Errors
Scope
Local Names
Function arguments are local to the function call. Reusing a name inside the function does not overwrite the outer value.
Program
Play the script to see outer x stay 5 while the function uses its own x.
scope.R
x <- 5
bump <- function(x) { x + 1 }
inside <- bump(10)
label <- paste(x, inside, sep = ":")
cat(label, "\n", sep = "")
scope
Scope controls which value a name refers to.
argument
The function argument `x` is local to the call.
outer value
The outer `x` remains unchanged after `bump(10)`.