I have some event data that I want to gather in one column. At the moment the data include columns for events and other columns that contain the outcome of certain events. I want to include the outcomes as events in the data and also preserve the order. The data look like df
in the example below and I want to transform them so that they look like the desired
df.
a <- c("event1","event2","event3","event4")
b <- c("outcome1",'','','')
c <- c('','',"outcome3",'')
df <- data.frame(a,b,c)
d <- c("event1","outcome1","event2","event3","outcome3","event4")
desired <- data.frame(d)