I have the following tibble in R:
df <- tibble(desc=c("test1", "test2", "test3", "test4","test1"), code=c("X00.2", "Y10", "X20.234", "Z10", "Q23.2"))
I want to create a new dataframe as:
df <- tibble(desc=c("test1", "test1", "test2", "test3", "test3", "test3", "test3", "test4", "test1", "test1"), code=c("X00", "X00.2", "Y10", "X20", "X20.2", "X20.23", "X20.234", "Z10", "Q23", "Q23.2"))
How would I do this? I think I can do it with separate_rows in dplyr by manipulating the separator but not exactly sure.
Thank you in advance.
Here is one way using
tidyverse
functions.This returns