Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- detach("new_tmp")
- attach(new.env(), name="new_tmp")
- my_newenv <- as.environment("new_tmp")
- source("C:/Users/tmp/tmp.R", local=my_newenv)
- search()
- xxx <- "this should not be overwritten"
- y <- 10
- my_newenv$printing_func(10) # the result should be 20!
- print(my_newenv$xxx)
- # <<< R script imported using source() function >>>
- # >>>
- # >>>
- xxx <- "this overwrote"
- printing_func <- function(xx){
- xx + y
- print("it works")
- }
Add Comment
Please, Sign In to add comment