I have a tibble A such:
| X1 | X2 | X3 |
|---|---|---|
| x1_1 | x2_1 | x3_1 |
| x1_2 | x2_2 | x3_2 |
| x1_3 | x2_3 | x3_3 |
| x1_4 | x2_4 | x3_4 |
And a Vector Y: (X2,X1,X3,X1...)
I want to select into a single vector B: (x2_1,x1_2,x3_3,x1_4...) only the values in the table A, such the B[n] element it is selected within the column Y[n].
I'd like to do this within a tidyverse pipeline, I want to avoid any for or apply.
I tried, after conversions of Y into integers referring to the position of the columns of A:
A %>% add_column(Y = Y) %>%
mutate(B = .[,Y])
but it does not vectorize properly.