search for: vector_u

Displaying 1 result from an estimated 1 matches for "vector_u".

Did you mean: vector_1
2012 Jul 12
1
Modifying a list: what gets copied?
...igure out what goes on when a list gets copied - is it a shallow copy or a deep copy. I believe the following experiment isolates the difference: options(digits = 2) powers <- 4:6 n <- setNames(10 ^ powers, paste0("e", powers)) xs <- lapply(n, seq_len) zs <- lapply(xs, list) vector_u <- function(x) x[length(x) + 1L] <- 1L list_u <- function(x) z$a <- 1L library(microbenchmark) microbenchmark( vector_u(xs$e4), vector_u(xs$e5), vector_u(xs$e6), list_u(zs$e4), list_u(zs$e5), list_u(zs$e6) ) On my computer, I get Unit: microseconds expr mi...