R newbie. I am trying to create a co-occurrence matrix with horizontal data. I want to know which elements co-occur 'TRUE' together in rows.
Each row represents an article. Each article has many true/false variables marking the presence or lack of an element. There are 100 elements, abbreviated here, and over 10k of articles. So a 10,000 x 101 data frame.
dat <- read.table(text='"article" "element1" "element2" "element3" "element4"
1 "a house a home" "TRUE" "TRUE" "FALSE" "FALSE"
2 "cabin in the woods" "TRUE" "TRUE" "FALSE" "FALSE"
3 "motel is a hotel" "TRUE" "FALSE" "TRUE" "FALSE"', header=TRUE)
I tried following this co-occurrence question (Creating co-occurrence matrix), but it seems like since the data is organized differently, that approach wont work.
What would be helpful would be a matrix if 100 elements x 100 elements. Anyone have suggestions?