The diag() function has several uses, one of which is to take a vector as its input and create a square matrix with that vector on the diagonal. Create a 23-by-23 matrix eleven with the sequence 11 over 0 to 11 (i.e. 11, 10, …, 1, 0, 1, …, 10, 11).

(from: Cotton, 2013, Learning R, O’Reilly)