I have a small data frame:
gene_symbol<-c("DADA","SDAASD","SADDSD","SDADD","ASDAD","XCVXCVX","EQWESDA","DASDADS")
panel<-c("growth","growth","growth","growth","big","big","big","small")
Gene_states22<-data.frame(gene_symbol,panel)
and a vector with colors:
colors<-c("red","green","yellow").
I would like to create a dataframe like this:
gene_symbol panel color
1 DADA growth red
2 SDAASD growth red
3 SADDSD growth red
4 SDADD growth red
5 ASDAD big green
6 XCVXCVX big green
7 EQWESDA big green
8 DASDADS small yellow
In a few words to add a new column where "growth" matches to "red", "big" to "green" and "small" to "yellow". The issue is that the panel names wont be the same every time for example they may be "bob","sam","bill", and there may be up to 8 different names (and colors). Also the rows of the data frame will vary.