I have the following dataframe:
v1 v2 v3 v4 v5
0 t 1 12 N/A
1 t 0 34 N/A
2 t 1 45 N/A
5 f 0 76 N/A
12 f 0 98 N/A
45 t 1 45 M
I want to be able to construct the following confusion matrix on the two columns v2 and v3:
t | f
0 1 2
1 3 0
What is the most elegant way to do this in R
This is easily done with table
...
table(df$v3,df$v2)
f t
0 2 1
1 0 3