We can get the transpose
and concatenate to a vector
. Note that the transpose
converts to a matrix
and there is no need to call as.matrix
.
as.vector(t(mydata))
Or we can use unlist after splitting the rows into a list.
unlist(lapply(seq_len(nrow(mydata)), function(i) mydata[i,]))