[R] Dataset to single column matrix

Pete Brecknock Peter.Brecknock at bp.com
Wed Jan 8 02:30:12 CET 2014


Krishia wrote
> Hello,
> I am pretty new to R and would like to transform my 272x12 matrix into a
> 3264X1. I'm trying to have the setup change from:
> 
> 1,  2,  3,  4, 5,  6, 7,  8, 9, 10, 11, 12
> 13,14,15,16,17,18,19,20,21,22, 23, 24
> etc.
> 
> to
> 
> 1
> 2
> 3
> 4
> 5
> 6
> 7
> 8
> 9
> 10
> 11
> 12
> etc.
> 
> Any suggestions?
> Thanks in advance

Krishia

Is this what you are looking for?

# Create example matrice
m <- matrix(c(1,2,3,4,5,6,7,8,9,10,11,12), nrow=4, byrow=TRUE)

# Create vector
v <- c(t(m))

HTH

Pete



--
View this message in context: http://r.789695.n4.nabble.com/Dataset-to-single-column-matrix-tp4683231p4683238.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list