I have string vector that needs to be split and rearranged in a matrix in a certain way. I know how to do split/simple rearrange, but lost how my to rearrange how I want:
library(stringi)
vec = c("b;a;c","a;c","c;b")
q = stri_split_fixed(vec, ";", simplify = TRUE,fill=T)
View(q)
V1 V2 V3
b a c
a c
c b
Desired output
V1 V2 V3
a b c
a c
b c
Thank you! EDIT:
Letters above are for simplicity. Real options are (not exhaustive list): D-Amazon Marketplace
, U-Amazon
, D-Amazon
, U-Jet
, etc. Starts with U
and D
only, though.
Order - alphabetical but grouped by retailer. If too complicated - no order is OK