I have the following data structure
ID Type Values 1 A 5; 7; 8 2 A 6 3 B 2; 3
and I would like to reshape it to the fol
My shot:
a <- data.frame(id = 1:3, type = c("A", "A", "B"), values = c("5; 7; 8", "6", "2; 3")) g <- strsplit(as.character(a$values), ";") data.frame(id = rep(a$id, lapply(g, length)), type = rep(a$type, lapply(g, length)), values = unlist(g))