\begin{Schunk}
\begin{Sinput}
 x <- c(1,2,3,4,5,6,7,8,9)
 xmat <- matrix(x, ncol=3)
 xmat
\end{Sinput}
\begin{Soutput}
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
\end{Soutput}
\begin{Sinput}
 xmat[1,3]
\end{Sinput}
\begin{Soutput}
[1] 7
\end{Soutput}
\begin{Sinput}
 xmat[ ,2]
\end{Sinput}
\begin{Soutput}
[1] 4 5 6
\end{Soutput}
\begin{Sinput}
 xmat[2, ]
\end{Sinput}
\begin{Soutput}
[1] 2 5 8
\end{Soutput}
\begin{Sinput}
 apply(xmat, 2, sum)
\end{Sinput}
\begin{Soutput}
[1]  6 15 24
\end{Soutput}
\end{Schunk}
