Hi there!
I want to separate this sample:
library(dplyr)
library(tidyr)
example <- data.frame(data=c("Annie;7;4;1%;3%;Luciana;9;4%;2%;Lucas;1;2;3;7%;10%"))
And i need to separate it so every name has the proper information in the same column. Also, i do not know how long the "data" is, so i created a long vector with names
names<- paste0("name ",1:70,"")
And i separated the example like this:
example <- example %>% separate(data,into=c(names),sep="(%;[A-z])")
In this way i am able to separate all the cases, but i am missing the first and the last character (the only one that cares is the first one):
Annie;7;4;1%;3 | uciana;9;4%;2 | ucas;1;2;3;7%;10%
There is any way to split the information without loosing the first character? I am not good with regex.
Thank you!
EDIT:
Thanks to @andresrcs i was able to make it using regex (?<=%);(?=([a-zA-Z]))