Thanks to anybody who can shed light on this. I know that a
transpose of the matrix prior to reshaping with matrix() will equate to
the simpler call: matrix(...,byrow=T), but I am concerned that I am either
missing an important S-Plus programming concept or my S-Plus configuration
is faulty (unlikely since my S-Plus installation is recent).
> x
[,1] [,2]
[1,] 1 2
[2,] 3 4
> matrix(x,1,4)
[,1] [,2] [,3] [,4]
[1,] 1 3 2 4
> matrix(x,1,4,byrow=T)
[,1] [,2] [,3] [,4]
[1,] 1 3 2 4
> matrix
function(data = NA, nrow = 1, ncol = 1, byrow = F, dimnames = NULL)
{
if(missing(nrow))
nrow <- ceiling(length(data)/ncol)
else if(missing(ncol))
ncol <- ceiling(length(data)/nrow)
dim <- c(nrow, ncol)
if(length(dim) != 2)
stop("nrow and ncol should each be of length 1")
if(byrow)
t(array(data, dim[2:1], rev(dimnames)))
else array(data, dim, dimnames)
}
Thanks,
REY DE CASTRO
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news