The tranpose of a matrix

In R, matrices may be constructed using the "matrix" function and the transpose of $A$, $A^\prime$, may be obtained in R by using the "t" function:


\texttt{A<-matrix(1:6, nrow=3)}

$\texttt{t(A)}$

Details
If $A$ is an $n \times m$ matrix with element $a_{ij}$ in row $i$ and column $j$, then $A^\prime$ or $A^T$ is the $m\times n$ matrix with element $a_{ij}$ in row $j$ and column $i$.
Examples
\begin{xmpl}

Consider a vector in R
\begin{lstlisting}
x<-1:4
x
[1] 1 2 3 4
t(x)
     [,1] [,2] [,3] [,4]
[1,] 1 2 3 4
matrix(x)
     [,1]
[1,] 1
[2,] 2
[3,] 3
[4,] 4
t(matrix(x))
     [,1] [,2] [,3] [,4]
[1,] 1 2 3 4
 
\end{lstlisting}
\begin{notes}
Note that the first solution gives a $1 \times n$ matrix and the second solution gives a $n \times 1$ matrix.
\end{notes}
\end{xmpl}