[R] as.matrix and one row
Federico Calboli
f.calboli at imperial.ac.uk
Tue Mar 28 17:47:10 CEST 2006
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
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
More information about the R-help
mailing list