I have a dataframe in R where one column (say column A) names other columns. For example,
colA colB colC colD
'colB' 1 2 3
'colD' 4 5 6
I want to create a new column where I extract the value in the column named by column A. For example, in the above table, I would like to create a new column whose value is 1 in the first row and 6 in the second row. What is the best way to automate the construction of such a column? I would especially appreciate if there is some way to do this within the tidyverse, but would be open to other solutions if those are considered better.