I'm working with a very raw set of data and need to shape it up in order to work with it. I am trying to split selected columns based on seperator '|'
d <- data.frame(id = c(022,565,893,415),
name = c('c|e','m|q','w','w|s|e'),
score = c('e','k|e','e|k|e', 'e|o'))
Is it possible to split the dataframe at one so it looks like this in the end.
df <- data.frame(id = c(22,22,565,565,565,565,893,893,893,415,415,415,415,415,415),
name = c('c','e','m','m','q','q','w','w','w','w','w','s','s','e','e'),
score = c('e','e','k','e','k','e','e','k','e','e','o','e','o','e','o'))
So far I've tried various different string split funtions but haven't had much luck :(
Can anybody help?