I have data as follow:
df
id  1  2  3  4    type
1   A  A  B  NA    H1
2   A  C  NA NA    H2
3   B  A  A  A     H1
I want to transform based on column two (df[,2]) to column five (DF[,5])
df_trans
id  tras_col   type
1     A         H1
1     A         H1
1     B         H1
2     A         H2
2     C         H2
3     B         H1
3     A         H1
3     A         H1
3     A         H1
How can I do it in R?
 
    