I have a sample data frame
samp_df <- data.frame(x1=c(1,3,5,7,9),x2=c(2,4,6,8,10))> samp_df x1 x21 1 22 3 43 5 64 7 85 9 10
I have another data frame which contains variable str and sis_str
samp2_df <- data.frame(str=c(x1,x1,x2,x2,x1),sis_str=c(1,2,4,5,3))> samp2_df str sis_str1 x1 12 x1 23 x2 44 x2 55 x1 3
The objective is to create another variable "sim" in the samp2_df data frame which contains the value from samp_df,such that the variable sis_str should match the row name of the first data frame and variable str should match the column name of the first data frame
So the output should be
> samp2_df str sis_str sim1 1 1 12 1 2 33 2 4 84 2 5 105 1 3 5