Mam tabeli, która wygląda następująco:R: Dodaj kolumnę do tabeli z danymi z innej tabeli
Table1 <- data.frame(
"Random" = c("A", "B", "C"),
"Genes" = c("Apple", "Candy", "Toothpaste"),
"Extra" = c("Up", "", "Down"),
"Desc" = c("Healthy,Red,Fruit", "Sweet,Cavities,Sugar,Fruity", "Minty,Dentist")
)
podając:
Random Genes Extra Desc
1 A Apple Up Healthy,Red,Fruit
2 B Candy Sweet,Cavities,Sugar,Fruity
3 C Toothpaste Down Minty,Dentist
mam inną tabelę z opisem i chcesz dodać kolumny z genami. Na przykład Tabela 2 będzie:
Table2 <- data.frame(
"Col1" = c(1, 2, 3, 4, 5, 6),
"Desc" = c("Sweet", "Sugar", "Dentist", "Red", "Fruit", "Fruity")
)
Dawanie:
Col1 Desc
1 1 Sweet
2 2 Sugar
3 3 Dentist
4 4 Red
5 5 Fruit
6 6 Fruity
Chcę dodać kolejną kolumnę Table2 nazwie „Geny” odpowiadający „opis produktu” z obu tabel i dodaje genów z Table1 do otrzymujemy:
Col1 Desc Gene
1 1 Sweet Candy
2 2 Sugar Candy
3 3 Dentist Toothpaste
4 4 Red Apple
5 5 Fruit Apple
6 6 Fruity Candy
miałem pośmiać na wartość 'Toothpaste' dla' Gene'. –