Split row in multiple rows

I have a dataframe like this:

a <- c("a","b", "c", "d")
b <- c(7, 5, 4, 3)
c <- c("ABc","D", "EF", "BCEF")

m <- data.frame(a, b, c)

I want to subdivide each row into several rows, depending on how many letters are contained in the last column. So, I want a final dataset like this:

a1 <- c("a","a","a", "b", "c", "c", "d", "d", "d", "d")
b1 <- c(7, 7, 7,5, 4, 4, 3, 3, 3, 3)
c1 <- c("A","B", "C", "D", "E", "F", "B", "C", "E", "F")

m1 <- data.frame(a1, b1, c1)

How can I do?

library(tidyverse)
m %>% separate_rows(c, sep = "(?<=.)(?=.)")

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.