Created
November 5, 2021 21:54
-
-
Save slwu89/a294203e6d6679b923276030516684d7 to your computer and use it in GitHub Desktop.
when do things get copied in R?
This file contains hidden or 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
fn_list <- function(y){ | |
y$a <- y$a + 1 | |
return(y) | |
} | |
fn_env <- function(y){ | |
y$a <- y$a + 1 | |
} | |
x <- list(a=matrix(1:9,3,3),b=matrix(1:36,6,6)) | |
.Internal(inspect(x)) | |
x <- fn_list(x) | |
.Internal(inspect(x)) | |
y <- list2env(list(a=matrix(1:9,3,3),b=matrix(1:36,6,6))) | |
.Internal(inspect(y)) | |
fn_env(y) | |
.Internal(inspect(y)) | |
stopifnot(x$a == y$a) | |
stopifnot(x$b == y$b) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment