tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
12
Task/Scope-modifiers/R/scope-modifiers-5.r
Normal file
12
Task/Scope-modifiers/R/scope-modifiers-5.r
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
d <- data.frame(a=c(2,4,6), b = c(5,7,9))
|
||||
also <- c(1, 0, 2)
|
||||
with(d, mean(b - a + also)) #returns 4
|
||||
|
||||
## with() is built in, but you might have implemented it like this:
|
||||
|
||||
with.impl <- function(env, expr) {
|
||||
env <- as.environment(env)
|
||||
parent.env(env) <- parent.frame()
|
||||
eval(substitute(expr), envir=env)
|
||||
}
|
||||
with.impl(d, mean(b - a + also))
|
||||
Loading…
Add table
Add a link
Reference in a new issue