z <- duplication(n = 100, condensed = TRUE)
object.size(z) # 40.5 Kb of storage
z <- duplication(n = 100, condensed = FALSE)
object.size(z) # 80.6 Kb of storage
D100 <- duplication(n = 100, matrix = TRUE)
object.size(D100) # 202 Mb of storage, do not request this matrix!
# a small example
D3 <- duplication(n = 3, matrix = TRUE)
a <- matrix(c( 1, 2, 3,
2, 3, 4,
3, 4, 5), nrow = 3)
upper <- vech(a)
v <- D3 %*% upper
all(vec(a) == as.vector(v)) # vectors are equal!
Run the code above in your browser using DataLab