Hi,
You could use: library(stringr) ?str_sub() lapply(2:3,function(i) if(i==2) str_sub(x,end=i) else str_sub(x,i)) #[[1]] #[1] "a1" "a2" "a1" #[[2]] #[1] "b1" "b2" "b2" A.K. ----- Original Message ----- From: Johannes Radinger <johannesradin...@gmail.com> To: r-help@r-project.org Cc: Sent: Wednesday, March 13, 2013 4:37 AM Subject: [R] string split at xth position Hi, I have a vector of strings like: c("a1b1","a2b2","a1b2") which I want to spilt into two parts like: c("a1","a2","a2") and c("b1","b2,"b2"). So there is always a first part with a+number and a second part with b+number. Unfortunately there is no separator I could use to directly split the vectors.. Any idea how to handle such cases? /Johannes ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.