Created
July 7, 2012 10:14
-
-
Save JWiley/3065740 to your computer and use it in GitHub Desktop.
Scoping Fun in R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## In the end, what is the twelth column of 'dat', a, and b? | |
## why does the local() not matter in thirteen? | |
a <- 10 | |
b <- 10 | |
dat <- local( | |
data.frame( | |
first = b, | |
second = a <- 0 -> b, | |
third = a <- rnorm(10, mean = a), | |
fourth = a / 2, | |
fifth = a <- rnorm(10, mean = a <- b), | |
sixth = a * rnorm(10, b) -> a, | |
seventh = b <- a^2, | |
eigth = {rm(b); 1:10}, | |
ninth = a * b, | |
tenth = b <<- a -> b, | |
eleventh = {rm(a); b <- 10:1}, twelth = a, | |
thirteenth = local(a <<- b -> a) | |
) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment