How to create and/or convert to it

They can be create by array() or by matrix():

  • array(vector, dim = length(data), dimnames = NULL)

dimnames is optional but will be used later.

  • matrix(vector, nrow = 1, ncol = 1, byrow = FALSE, dimnames = NULL)

  • cbind and rbind can also be used (sometimes in conjunction with do.call())

Be careful do.call will use the recycle rule.

  • simplify2array(): has the name suggest: list of vector of same length
    -> sapply() is lapply() + (if simplify = TRUE, the default) simplif2array
x <- list(a = runif(10), b = rnorm(15))
sapply(x, function(e) c(Min = min(e), Max = max(e)))
##             a         b
## Min 0.1035515 -1.003478
## Max 0.9964182  1.652526
  • table() creates contingency table: matrix/array