Supposing a dataframe like this:
# example dataset
df <- data.frame(
rowid = 1:3,
a = c("ax","cz","by"),
b = c("cy","ax","bz"),
c = c("bz","ay","cx")
)
What would an efficient approach be to achieving the following transformation?
#> # A tibble: 3 x 4
#> rowid a b c
#> <int> <chr> <chr> <chr>
#> 1 x z y
#> 2 x y z
#> 3 y z x
The goal is to take the second character of each bigram and sort it into columns picked-out by the first character, for each row.
If possible, it would be useful to compare base R and Tidyverse solutions.