如何重复一行并粘贴列名呢?

时间:2017-11-28 15:45:13

标签: r

我有一个看起来像这样的数据,它有NA个地方。

df<- structure(list(Proteins = c("A0A0J9YWL0;Q9Y4K1-2;Q9Y4K1", "H0YLZ8;P15144", 
"P08238", "P63261;P60709", "P10809", "A0A0G2JS76;A0A0G2JMX7", 
"A0A0G2JS76;A0A0G2JMX7;", "A0A087WYX8;Q14CM0", "B4DNK4;P14618-3;P14618;P14618-2;H3BR70", 
"A0A0G2JS76;A0A0G2JMX7", "A0A0G2JS76;A0A0G2JMX7", "P07737;K7EJ44"
), `data type BO_10min` = c(NA, "By whama", NA, "By whama", "By TM/T", 
"By TM/T", "By TM/T", NA, NA, "By TM/T", "By TM/T", NA), `data type BO1_1min` = c(NA, 
NA, "By TM/T", "By TM/T", "By TM/T", "By TM/T", "By TM/T", NA, 
"By TM/T", "By whama", "By TM/T", "By TM/T"), `data type BO1_20min` = c(NA, 
NA, NA, "By whama", NA, "By TM/T", "By whama", NA, NA, "By TM/T", 
"By TM/T", NA)), .Names = c("Proteins", "data type BO_10min", 
"data type BO1_1min", "data type BO1_20min"), class = c("tbl_df", 
"tbl", "data.frame"), row.names = c(NA, -12L))

我正试图像这样得到输出

H0YLZ8;P15144   data type BO_10min
P08238          data type BO1_1min
P63261;P60709   data type BO_10min
P63261;P60709   data type BO1_1min
P63261;P60709   data type BO1_20min
P10809          data type BO_10min
P10809          data type BO1_1min
.
.
.

这意味着如果列的单元格中有一个字符串对应于每一行,它将再次粘贴该行并粘贴该列的名称

0 个答案:

没有答案