t {base} | R Documentation

## Matrix Transpose

### Description

Given a matrix or `data.frame` `x`, `t` returns the transpose of `x`.

### Usage

    t(x)

### Arguments

`x` | a matrix or data frame, typically.

### Details

A data frame is first coerced to a matrix: see `as.matrix`. When `x` is a vector, it is treated as “column”, i.e., the result is a 1-row matrix.

### References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

### See Also

`aperm` for permuting the dimensions of arrays.

### Examples

    a <- matrix(1:30, 5,6)
    ta <- t(a) ##-- i.e.,  a[i, j] == ta[j, i] for all i,j :
    for(j in seq(ncol(a)))
      if(! all(a[, j] == ta[j, ])) stop("wrong transpose")

[Package base version 2.3.1 Index]