[R] How use a matrix method?

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sun Apr 19 10:32:24 CEST 2009


Grześ wrote:
> Why when I want to find my value from matrix I get: 2,3,4,1,2? I think that I
> should get: 1,2,3,4,7,8.
> 
>> macierz=matrix(1:4,7,8)

That's

matrix(data=1:4, nrow=7, ncol=8)

a 7x8 matrix with the numbers 1 to 4 repeated columnwise.

You probably want something like matrix(c(1:4, 7, 8))

-- 
    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
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list