I've never posted on here before, but I figured I would give it a shot..
I've spent some time googling, and can't find exactly what I am looking for... I have a data frame like this:
df <- structure(list(response = c("Topic1", "Topic10", "Topic11", "Topic12",
"Topic13", "Topic14", "Topic15", "Topic16", "Topic17", "Topic18",
"Topic19", "Topic2", "Topic20", "Topic21", "Topic22", "Topic23",
"Topic24", "Topic25", "Topic26", "Topic27", "Topic28", "Topic29",
"Topic3", "Topic30", "Topic31", "Topic32", "Topic33", "Topic34",
"Topic35", "Topic36", "Topic37", "Topic38", "Topic39", "Topic4",
"Topic40", "Topic41", "Topic42", "Topic43", "Topic44", "Topic45",
"Topic46", "Topic47", "Topic48", "Topic49", "Topic5", "Topic50",
"Topic6", "Topic7", "Topic8", "Topic9"), judgement.yNTA = c(0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
judgement.yYTA = c(0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)),
class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24",
"25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35",
"36", "37", "38", "39", "40", "41", "42","43","44","45","46","47","48","49", "50"))
where I have coded 1=statistically significant value, 0=non-statistically significant with 50 topics. I want to update a blank 50x50 matrix with +1 when two values are both statistically significant...
Code for blank matrix:
mymatrix <- matrix( , nrow = 50, ncol = 50)
For example, Topic25 and Topic31 are both statistically significant for the NTA votes... so I want the matrix to reflect this by adding a 1 to [25, 31] and [31, 25] in my matrix. I also want to ensure that I am not replacing the value with "1", but adding 1 to the existing value, because I want to see how many times these topics show up together across different dataframes! I also want to make sure that this code would look at both columns when filling the matrix
I don't really know where to start with this, and would appreciate any tips on building a command that would work! Thanks in advance!