Hi I can't find a solution to prepare my data.
At the moment I have two Vectors like below and would like to match those to the corresponding titles in an extra column. Which Names match with which title is indicates by an entry in the name data called "Top"
name <- c("Top", "Name1", "Name2", "Top", "Name3", "Top", "Name4", "Name5")
title <- c("Title1", "Title2", "Title3")
What the result should look like:
Title1 Name1
Title1 Name2
Title2 Name3
Title3 Name4
Title3 Name5
An idea is to get the number of names between the "Top" entries and replicate the titles according to those numbers but how can I do that?