I am a heavy user of Excel and am learning R and the easy-to-use R package dplyr. I frequently use Excel's index(...,match(...)) formula combination to pull in (look up) target values from a column. How would I perform the same thing, in R and using dplyr, as shown in the Excel illustration shown below? In R I am trying to replicate column G labeled "Match", and the formulas for that column are shown in the columns to its right highlighted yellow and labeled "Match Column Formula".
I am using the Excel and companion R code to show a series of step-wise calculations, in case that column G looks a but cumbersome!
Code to reproduce the starting dataframe in this example:
myData <-
data.frame(
Element = c("A","A","C","A","B","B"),
Code1 = c(0,0,0,0,1,1),
Code2 = c(1,2,1,3,1,2),
Code3 = c(0,0,0,0,1,2),
Code4 = c(0,0,0,0,1.1,1.2)
)
