In this toy reproducible example below, I have a data.frame with two columns.
id
dump
: a string variable that acts as a "dump" for a bunch of characteristics ofid
and can have an arbitrary number of elements in each row. Indump
, characteristics are separated by ";" (obs: dump is Postgresql speak, don't know of a native R term for this).library(data.table)
original_data <- data.table(id=1:3,dump=c('a;b;c','x','t,y'))
I want to reshape this into a tidy format, with one row per id-characteristic pair. Preferably a data.table solution for performance.
This is the desired output
desired_data <- data.table(id=c(1,1,1,2,3,3),unduped=c('a','b','c','x','t','y'))