I have data like this:
data1=data.frame("long_customers"=c(TRUE, FALSE, FALSE, TRUE),
"long_partners"=c(FALSE, TRUE, FALSE, FALSE),
"short_customers"=c(FALSE, TRUE,TRUE,FALSE),
"short_partners"=c(FALSE,FALSE,NA,NA))
I want to transform/reshape this so it looks like:
data2=data.frame("x"=c("long","long","long","long","long","long","long","long", "short", "short", "short", "short", "short", "short", "short", "short"),
"y"=c("customers", "customers", "customers", "customer", "partners", "partners", "partners", "partners","customers", "customers", "customers", "customer", "partners", "partners", "partners", "partners"),
"event"=c(TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, NA, NA))
How do I get there? I'd appreciate any pointers and would love to get a data.table way of doing this.
Thanks!