Hello,
It's important, as Mara pointed out, that you could turn your questions into self-contained reprex.
If I understood correctly, maybe this piece of code could point you in the right direction:
library(dplyr)
x <- data.frame(
col1 = c("G8920","G7769","G7720","G7722","G8920","G5434","G7652","G7547","G7644","G5535")
)
x %>%
mutate(col2 = paste(head(col1), lead(col1,1), lead(col1,2), lead(col1,3))) %>%
slice(seq(1,n(),4)) %>%
select(col2)
#> # A tibble: 3 x 1
#> col2
#> <chr>
#> 1 G8920 G7769 G7720 G7722
#> 2 G8920 G5434 G7652 G7547
#> 3 G7720 G5535 NA NA
You're going to have problems with the last rows as you don't have "next strings to concatenate". Also, I'm fixing the length to 4 strings or less.
Hope it helps.
Regards,