x <- 10
g02 <- function(x){
x <- x + 1
return(x)
}
g02(x)
x + 1Activity: function scoping
Instructions:
- Work with a neighbor to answer the following questions
- To get started, download the class activity template file
- When you are finished, render the file as an HTML and submit the HTML to Canvas (let me know if you encounter any problems)
What will happen?
For each question, predict what will happen when the code is run. Then run the code and check whether your prediction was correct.
x <- 10
g02 <- function(x){
x <- x + 1
return(x)
}
x <- g02(x)
x + 1g02 <- function(y){
y <- y - 1
return(y)
}
g02(g02(20))