I want to transform the data frame on the basis on column house. so if the columns house have text seprated by ";" the add the text in new row. and also add the new column with head1, head2
library(dplyr)
library(tidyr)
df <- data.frame(Region = c("AU","USA","CA","UK","GE","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"))
df %>%
mutate(House = strsplit(House, ";"),
head= head) %>%
unnest(House)
the output should look like