I have a data frame that has two columns, one for gene symbols, and another for functional pathways. The pathways column has repeated values as there are a number of genes that belong with each pathway. I would like to reorder this dataset so that each column is a single pathway and each row in those columns is a gene that belongs in that pathway.
Starting dataframe:
data.frame(pathway = c("p1", "p1", "p1", "p1", "p2", "p2", "p2"),
gene.symbol = c("G1", "G2", "G3", "G4", "G33", "G43", "G10"))
Desired dataframe:
data.frame(p1 = c("G1", "G2", "G3", "G4"), p2 = c("G33", "G43", "G10",
""))
I know that not all columns will be the same length, and having blank values is preferable to NAs.
listrather than adata.frame, particularly since row 1, column 1 has nothing to do with row 1, column 2. - Nick Nimchuk