change the dataframe on the basis of column Region

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.

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,
                         g_num = if_else(g_l,cumsum(g_l),0)) |>
    separate_longer_delim(cols="House",delim=";") |> group_by(g_num) 

This topic was automatically closed 42 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.