I have a genetic dataset that looks like this:
Pathway       Gene
Pathway1      Gene1
Pathway1      Gene2
Pathway2      Gene3
Pathway2      Gene1
Pathway3      Gene1
Pathway3      Gene4
Pathway3      Gene5
I am looking to transpose the Pathways rows to columns, whilst keeping track of which genes are present in which pathway with 1s and 0s. Creating an output like this:
Gene  Pathway1  Pathway2  Pathway3
Gene1    1           1         1
Gene2    1           0         0
Gene3    0           1         0
Gene4    0           0         1
Gene5    0           0         0
My real data is around 3000 rows long, and I'm not confident in R so I've been playing with using t() but I'm not sure where to start with coding to get the binary counts I'm looking for - any help or suggestions on functions to try would help.
Input example data:
structure(list(Pathway = c("Pathway1", "Pathway1", "Pathway2", 
"Pathway2", "Pathway3", "Pathway3", "Pathway3"), Gene = c("Gene1", 
"Gene2", "Gene3", "Gene1", "Gene1", "Gene4", "Gene5")), row.names = c(NA, 
-7L), class = c("data.table", "data.frame"))
 
     
     
    