I have an empty data frame that looks like that:
df <- data.frame(Hugo_Symbol=c("CDKN2A", "JUN", "IRS2","MTOR",
"NRAS"),
A183=c(NA, NA, NA, NA, NA),
A240=c(NA, NA, NA, NA, NA),
A330=c(NA, NA, NA, NA, NA))
I would like to use a larger data frame to populate the previous one. The structure of the larger data frame is the following:
df2 <- data.frame(Hugo_Symbol=c("CDKN2A", "JUN", "IRS2","MTOR",
"NRAS", "TP53", "EGFR"),
A183=c(2.3, 3.3, 2.6, 4.7, 1.2, 5.7, 3.4),
A240=c(1.3, 2.3, 4.6, 5.7, 2.2, 7.7, 1.4),
A330=c(0.3, 2.3, 1.6, 1.7, 4.2, 1.7, 4.4),
A335=c(1.3, 0.3, 0.6, 0.7, 0.2, 0.7, 0.4),
A345=c(0.3, 4.3, 4.6, 4.7, 4.2, 4.7, 0.4))
My desired output should look like that:
Hugo_Symbol A183 A240 A330
1 CDKN2A 2.3 1.3 0.3
2 JUN 3.3 2.3 2.3
3 IRS2 2.6 4.6 1.6
4 MTOR 4.7 5.7 1.7
5 NRAS 1.2 2.2 4.2
I tried to use dplyr package, specifically semi_join() function, but it returns empty table to me.