I have two Matrix with different width.
Matrix_A
'data.frame':412 obs. of 5 variables:
$ R : num 2 18 18 2 2 18 18 2 2 2 ...
$ NS: num 4.82e+09 4.82e+09 4.82e+09 4.82e+09 4.82e+09 ...
$ NP: chr "20000070000" "20000000090000" "20000000060000" "20000000010000" ...
$ NG: chr "TE" "EC" "ET" "HT" ...
$ DC : logi NA NA NA NA NA NA ...
Matrix_B
'data.frame': 2687 obs. of 4 variables:
$ R : num 18 2 2 2 18 2 2 2 18 2 ...
$ NS : num 4.81e+09 4.81e+09 4.81e+09 4.81e+09 4.81e+09 ...
$ NP :chr "20000000000400" "2000000000600" "2000000001000" "20000000007000" ...
$ NG: chr "HT" "HT" "TT" "TY" ...
I would like to know what elements of the Matrix A are present in the Matrix B, and to do this I wrote this code.
Matrix_B$Results <- ifelse((Matrix_A$R %in% Matrix_B$R),
ifelse((Matrix_A$NS %in% Matrix_B$NS),1,0))
This dosen't give me a error, but the result is not correct.
I tried this
Matrix_B$Results <- ifelse((Matrix_A$R %in% Matrix_B$R) &
(Matrix_A$NS %in% Matrix_B$NS),1,0))
but dosen't work.