## Tuesday, February 7, 2012

### Why I hate programming (part 4 of n)

back to R:

1. Writing some code, seemed a bit slow, looked to stack overflow for help:

reason: R's wiki page is dead

2. Populating a matrix from a vector. (In R, a matrix is different from an array is different from a vector.)
vec <- 1:9mat <- as.matrix(vec, nrow = 3, ncol = 3)# mat is 9x1 (silent fail on invalid arguments nrow and ncol)mat2 <- matrix(vec, nrow = 3, ncol = 3)# mat2 is 3x3

3. How big is my vector?
vec <- 1:9mat2 <- as.matrix(vec, nrow = 3, ncol = 3)nrow(vec) # NULLnrow(mat2) # 3NROW(vec) # 3NROW(mat2) # 3