'R: Confusion matrix from list of relevant variables

I am trying to set up a simulation but I struggle with something.

I know which variables are relevant or not in the beginning as I set them myself. They are stored in a beta matrix taking 0 if insignificant and 1 (same amplitude for all) if they are significant.

I run a procedure which gives me its list of relevant variables. The problem is that, this procedures is not giving me a 0-1 matrix but just a list of the selected variables using their "place" in number (so 38 for the 38th variable in my list). I know wish to test whether this procedure is powerful or not and I want to display the confusion matrix (among other things).

Below you can find those two vectors. I've tried using the "%in%" operator but it does not work and I don't want to use a loop as the simulation takes enough time already.

Thanks in advance!


res=c( 1, 9, 11 ,18, 19, 25, 26, 28, 31, 34 ,37 ,38, 39, 42 ,43 ,47 ,48, 50) #From my procedure
beta=c(1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source