transpose: Vector and Matrix Transpose

Description Usage Arguments Value Author(s) See Also Examples

View source: R/transpose.R

Description

transpose is a wrapper function around the t function, which tranposes matrices. Contrary to t, transpose processes vectors as if they were row matrices.

Usage

1
  transpose(object = NULL)

Arguments

object

A vector or a matrix.

Value

Return a matrix which is the exact transpose of the vector or matrix x

Author(s)

Sebastien Bihorel (sb.pmlab@gmail.com)

See Also

t

Examples

1
2
3
4
5
6
  1:6
  t(1:6)
  transpose(1:6)
  mat <- matrix(1:15,nrow=5,ncol=3)
  mat
  transpose(mat)

Example output

Loading required package: Matrix
[1] 1 2 3 4 5 6
     [,1] [,2] [,3] [,4] [,5] [,6]
[1,]    1    2    3    4    5    6
     [,1]
[1,]    1
[2,]    2
[3,]    3
[4,]    4
[5,]    5
[6,]    6
     [,1] [,2] [,3]
[1,]    1    6   11
[2,]    2    7   12
[3,]    3    8   13
[4,]    4    9   14
[5,]    5   10   15
     [,1] [,2] [,3] [,4] [,5]
[1,]    1    2    3    4    5
[2,]    6    7    8    9   10
[3,]   11   12   13   14   15

optimbase documentation built on Jan. 27, 2022, 1:14 a.m.