"Mike Jones" <[EMAIL PROTECTED]> writes: > hi all, > > i'm trying to get elements in a matrix into a vector. i need a > "streamlined" way to do it as the way i'm doing it is not very > serviceable. an example is a 3x3 matrix like > > 0 0 3 > 2 0 0 > 0 4 0 > > to a vector like > > 3 2 4
You need to explain the rules of the game better. Do you mean like > M <- matrix(c(0,0,3,2,0,0,0,4,0),3,byrow=T) > rowSums(M) [1] 3 2 4 or > x <- c(t(M)) ; x[x!=0] [1] 3 2 4 or ...? -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
