[R] peculiar matrices
Ben Bolker
bolker at ufl.edu
Fri Oct 21 23:32:44 CEST 2005
As far as I can tell from reading The Fine Documentation
(R Language Definition and Intro to R), matrices are supposed
to be of homogeneous types. Yet giving matrix() an inhomogeneous
list seems to work, although it produces a peculiar object:
v = list(1:3,4,5,"a")
m = matrix(v,nrow=2)
m
[,1] [,2]
[1,] Integer,3 5
[2,] 4 "a"
m[1,]
[[1]]
[1] 1 2 3
[[2]]
[1] 3
(this is R 2.1.1, running under Linux)
Should there be a check/error? Or is this just analogous to
the joke about going to the doctor and saying "it hurts when
I do this", and the doctor saying "well then, don't do that"?
Ben Bolker
More information about the R-help
mailing list