matrix(data=NA, nrow=<<see below>>, ncol=<<see below>>, byrow=F, dimnames=NULL) is.matrix(x) as.matrix(x)
is.matrix returns TRUE if dim(x) is of length 2, and FALSE otherwise.
as.matrix returns x, if x is a matrix; otherwise, a matrix with data from x and dimension c(length(x),1).
Matrix objects are those that have an attribute dim of length 2. The objects may also have an attribute dimnames. If so, this is a list of 2 character vectors, each of which is either of length zero or else gives the labels corresponding to the levels of the corresponding subscript in the matrix.
If mat is an S-PLUS matrix, then as.vector(mat) is a vector containing the data values for mat in normal array order: the first subscript varies most rapidly.
The byrow argument should be set to TRUE if the data values were read from a file arranged by rows.
m <- matrix(0, 4, 5) # a 4 by 5 matrix of zerosmatrix(1:10, 5) # a 5 by 2 matrix matrix(1:10, ncol=2) # the same thing
mm <- matrix( scan("mfile"), ncol=5, byrow=TRUE) #read all rows from the file