Actually i want to change the data frame on the basis of column Region.
i want to check the column Regions if there is any text in column house for "!UK" in region and for that add a new row and paste the text in new row in column house.
library(tidyverse)
df <- tibble(Region = c("AU","USA","CA","USA","!UK","AU","USA","CA","!UK"),
lock = c(1,1,NA,1,NA,1,NA,1,NA),
type= c("sale",NA,NA,"target","target",NA,"sale",NA,"target"),
House =c("Tagore house","Gandhi house",NA,"Flexible;Tagore house;Gandhi house","Tagore house",NA,"Flexible;Gandhi house","Gandhi house","Gandhi house"))
step_1 <- df %>% mutate(g_l=replace_na(str_detect(House,
";"),0),
g_num = if_else(g_l,cumsum(g_l),0)) |>
separate_longer_delim(cols="House",delim=";") |> group_by(g_num)