I am trying to create the table below using tabular in latex.
Exploring the stack exchange for similar problems like this one has brought me to my current table:
\usepackage{multirow}
\begin{document}
\begin{table}[htbp]
\caption{Confusion Matrix}
\begin{center}
\begin{tabular}{|c|c|c|c|}\hline\vline
\multirow{1}{*}{N=986}
& \multicolumn{3}{c}{Predicted} \\%
\cline{3-4}
\multirow{1}{*}{}
& No & Yes\\%
\hline
\multirow{2}{*}{Actual}
& \multirow{1}{*}{No} & TN = 27 & FP = 176\\%
\cline{2-4}
& \multirow{1}{*}{Yes} & FN = 9 & TP = 174\\%
\hline
\end{tabular}
\end{center}
\label{tab:confusion-matrix}
\end{table}
\end{document}
So far, this code produces the given table:
Now, how what should I change in order to make sure that N=986
would occupy a cell merging the first 2 rows and columns, while Predicted
occupies Row 1 and Columns 3 & 4, while No
and Yes
occupies the Row 2 and Columns 3 & 4 respectively? I have already tried to play around with the code but this one was the closest that I got to the intended output.
P.S.
I am also unsure why the vline is not there in the rightmost part of the first two cells. I am really having quite a trouble with table manipulation with LaTeX.
Best Answer
after removing unnecessary
multirow
s and\vline
, and adding missed ampersand: