\begin{Schunk}
\begin{Sinput}
 table(as.integer(myfactor), as.integer(yourfactor), exclude = NULL)
\end{Sinput}
\begin{Soutput}
    1 2 3 <NA>
  1 2 0 0    0
  2 0 0 0    2
  3 0 0 0    2
  4 0 0 2    0
  5 0 2 0    0
\end{Soutput}
\end{Schunk}
