blob: 246ba1e577630810696889122b2a23781542c754 [file] [log] [blame]
% File src/library/base/man/t.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2007 R Core Team
% Distributed under GPL 2 or later
\name{t}
\alias{t}
\alias{t.default}
\alias{t.data.frame}
\title{Matrix Transpose}
\description{
Given a matrix or \code{\link{data.frame}} \code{x},
\code{t} returns the transpose of \code{x}.
}
\usage{
t(x)
}
\arguments{
\item{x}{a matrix or data frame, typically.}
}
\details{
This is a generic function for which methods can be written. The
description here applies to the default and \code{"data.frame"} methods.
A data frame is first coerced to a matrix: see \code{\link{as.matrix}}.
When \code{x} is a vector, it is treated as a column, i.e., the
result is a 1-row matrix.
}
\value{
A matrix, with \code{dim} and \code{dimnames} constructed
appropriately from those of \code{x}, and other attributes except
names copied across.
}
\note{
The \emph{conjugate} transpose of a complex matrix \eqn{A}, denoted
\eqn{A^H} or \eqn{A^*}, is computed as \code{\link{Conj}(t(A))}.
}
\references{
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)
\emph{The New S Language}.
Wadsworth & Brooks/Cole.
}
\seealso{
\code{\link{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")
}
\keyword{array}