[R] How to force a vector to be column or row vector?

Gabor Grothendieck ggrothendieck at gmail.com
Thu Feb 2 15:43:10 CET 2006


On 2/2/06, Liaw, Andy <andy_liaw at merck.com> wrote:
> From: Gabor Grothendieck
> >
> > Try this:
> >
> >
> > rbind(c(x))
> > cbind(c(x))
> > t(c(x))
>
> The c() is not needed above.

The poster asked for an expression that would work "regardless of
the original form" of the vector -- row, column or neither.  The c
gets it into a known form first.  For example:

> cbind(matrix(1,1,3))  # not a column vector!
     [,1] [,2] [,3]
[1,]    1    1    1




More information about the R-help mailing list