Federico Calboli <[EMAIL PROTECTED]> writes: > Hi All, > > I have the following problem: > > x = c(1,2) > x > [1] 1 2 > > as.matrix(x) > [,1] > [1,] 1 > [2,] 2 > > BUT, if I add: > > y = c(3,4) > > as.matrix(rbind(x,y)) > [,1] [,2] > x 1 2 > y 3 4 > > It does not transpose. Since I will need as.matrix() for a list of data > that is in one or more lines, I need as.matrix to behave in a consisten > fashions, so I get
Well, it's a NOP since the argument is a matrix already. R is not "transposing" in the first case either, since the argument is not a matrix. However, the convention is that vectors are treated as column vectors, even though they print horisontally. rbind(x) should get you to where you want soon enough. > as.matrix(x, whatever) > [,1] [,2] > x 1 2 > > and > > as.matrix(rbind(x,y), whatever) > [,1] [,2] > x 1 2 > y 3 4 > > I tried byrow =T, does not make a thing. > > Regards, > > Federico Calboli > > -- > Federico C. F. Calboli > Department of Epidemiology and Public Health > Imperial College, St Mary's Campus > Norfolk Place, London W2 1PG > > Tel +44 (0)20 7594 1602 Fax (+44) 020 7594 3193 > > f.calboli [.a.t] imperial.ac.uk > f.calboli [.a.t] gmail.com > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > -- 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 ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html