search for: list_u

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

Did you mean: list_
2012 Jul 12
1
Modifying a list: what gets copied?
...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 min lq median uq max 1 list_u(zs$e4) 122...