I am trying to loop through 53 rows in a data.frame and create an adjacency matrix with the results. However, my efforts continue to be stalled by the fact that the loop will not run correctly.
I have tried to create matches as well as applying numerous count() functions, without success.
MRE: (In truth, the data is a lot larger so my unique search is actually 217k elements)
df1<-data.frame(col1=c(12345,123456,1234567,12345678),
col2=c(54321,54432,12345,76543),
col3=c(11234,12234,1234567,123345),
col4=c(54321,54432,12345,76543))
search<-c(12345,1234567,75643,54432)
I would like to loop through each row and update a new matrix/df where the count per number in [search] would be the output.
Ex:
df2
        12345     1234567    75643    54432
row1    TRUE       TRUE      FALSE    FALSE
row2    FALSE      FALSE     TRUE      TRUE
row3    TRUE       TRUE      FALSE    FALSE
row4    TRUE       FALSE     TRUE     TRUE
 
     
    