I have a data frame that maps some ids to a list of versions:
id versions
1 1, 2, 4
2 1
3 3, 4
It can be created with the following code:
df <- data.frame(id=c(1, 2, 3),
versions=c("1 2 4", "1", "3 4"),
stringsAsFactors=F)
df$versions <- strsplit(df$versions, " ")
Notice that each element of the versions
column is a list.
How to normalize this data frame? I need to get a data frame like this:
id version
1 1
1 2
1 4
2 1
3 3
3 4