I want to use variable names in R for comparison with String-Data in an id-Variable.
Table 1 shows how my sample table is currently looking and Table 2 shows what I want to achieve. In Table 2 corresponding values are copied into a new variable "newid" if the variable id matches the column name. The other values are also copied into new variables for easier calculating
id a b c newid
c 1 2 3
a 4 2 1
b 5 8 9
id a b c newid rest1 rest2
c 1 2 3 3 1 2
a 4 2 1 4 2 1
b 5 8 9 8 5 9
Thank you in advance