1

I have a matrix measuring 91 x 2 (i.e 91 rows and two columns).

 mat1 <- matrix(1:182, 91, 2)

I need to create a vector from the said matrix of one row. I can do that with the following:

mat2 <- matrix(mat1, nrow = 1, byrow = TRUE).

However, I would like to have each row in the original matrix to be represented one after another. Currently it's taking all of column 1 then all of column 2 and joining those together sequentially. Whilst I need them to be in one long row, like this: 1,92,2,93,3,94 etcMeaning the structure ultimately would be 1,182 (i.e. one row with 182 columns).

How can I achieve this?

Thanks.

Dasr
  • 777
  • 6
  • 16

1 Answers1

0

We can transpose the matrix and convert it to a vector

c(t(mat1))
akrun
  • 874,273
  • 37
  • 540
  • 662