I want a function that takes an input vector, the number of columns and returns a matrix as follows. x<- 1:5 foo(x, nc=3) 1 5 4 2 1 5 3 2 1 4 3 2 5 4 3 Thanks again for any help. Bill