Hello - I have two sample datasets which are as follows:
structure(list(CellType = structure(c(1L, 2L, 3L, 3L, 1L, 4L,
4L), .Label = c("CellA", "CellB", "CellC", "CellD"), class = "factor"),
Gene1 = c(0.1, 0.2, 0.1, 0.3, 0.5, NA, NA), Gene2 = c(0.1,
0.2, 0.1, 0.3, 0.5, 0.2, 0.2), Gene3 = c(0.1, 0.2, 0.1, 0.3,
0.5, 0.5, 0.5)), class = "data.frame", row.names = c(NA,
-7L))
And here is the second one:
structure(list(CellType = structure(c(1L, 1L, 2L, 3L, 4L), .Label = c("CellD",
"CellX", "CellY", "CellZ"), class = "factor"), Gene1 = c(10L,
20L, 20L, 30L, 10L), Gene2 = c(0.1, 0.2, 0.1, 0.3, 0.5), Gene3 = c(0.1,
0.2, 0.1, 0.3, 0.5)), class = "data.frame", row.names = c(NA,
-5L))
I would like to add items in 'Gene 1' column that match in 'Cell Type' column from the second data frame to the first one. In this case, only two cell type items match which are 'CellD'. Is there a way for me to add the corresponding values of '10' and '20' from the Gene 1 column of my second dataframe into my 'NA' fields in dataframe # 1?
Thanks!