The input dataframe has a long format and contains info for one user into more than one rows.
Example
d_long <- data.frame( nameid = c("sally","sally","sally","Robert","annie","annie"), value = c("product1","ra","ent","ra","ra","product1"))
nameid value 1 sally product1 2 sally ra 3 sally ent 4 Robert ra 5 annie ra 6 annie product1
How could it be possible to transform it to a binary dataframe like this:
d_exist <- data.frame(nameid = c("sally","Robert","annie"), product1 = c(1,0,1), ra = c(1,1,1), ent = c(1,0,0))
nameid product1 ra ent 1 sally 1 1 1 2 Robert 0 1 0 3 annie 1 1 0