I\'m trying to use one column to determine which column to use as the value for another column It looks something like this:
X Y Z Target 1 a b
You could try apply rowwise like this:
apply
transform(df, TargetValue = apply(df, 1, function(x) x[x["Target"]])) # X Y Z Target TargetValue # 1 a b c X a # 2 d e f Y e # 3 g h i Z i