Adding new column for different rows based on the values present in the same row for a different column
aggregate(ind~row, na.omit(cbind(row = c(row(df)), stack(df))), paste, collapse = "_")
  row   ind
1   1 F1_F2
2   2 F1_F3
3   3 F1_F4


df <- structure(list(F1 = c(1L, 1L, 1L), F2 = c(1L, NA, NA), F3 = c(NA, 
1L, NA), F4 = c(NA, NA, 1L)), class = "data.frame", row.names = c(NA, 
-3L))


I have a dataframe with different combination of factors. each factor is presented in its column (see below)
F1   F2   F3   F4
1     1
1          1  
1                1

I want to add a new column at the end like below
F1   F2   F3   F4  trt
1    1             F1_F2
1          1       F1_F3
1               1  F1_F4

How do I create this column with conditional merging in R. Any advice would be appreciated!
