1

所以,我想将两列合并为一。这就是我的数据的样子:

> tbl_end

Sequence                                 modifications                  no_Ks      no_Ks_modif           V1
AAAAGAAAVANQGKK               [14] Acetyl (K)|[15] Acetyl (K)             2           2              [14] Acetyl 
AAAAGAAAVANQGKK               [14] Acetyl (K)|[15] Acetyl (K)             2           2              [14] Acetyl 
AAFTKLDQVWGSE                                [5] Acetyl (K)               1           1              [5] Acetyl 
AAIKFIKFINPKINDGE   [4] Acetyl (K)|[7] Acetyl (K)|[12] Acetyl (K)         3           3              [4] Acetyl 
AAIKFIKFINPKINDGE   [4] Acetyl (K)|[7] Acetyl (K)|[12] Acetyl (K)         3           3              [4] Acetyl 

我想在不干扰其他数据集的情况下合并列序列和修改。

新列的名称可能是“Seq_modif”

试图用粘贴来做,但这不是我想要的:

tbl_reo2 <- paste(tbl_end$Sequence,tbl_end$modifications)

所以这就是我想通过脚本实现的目标:

              Seq_modif                                                no_Ks      no_Ks_modif         V1
AAAAGAAAVANQGKK [14] Acetyl (K)|[15] Acetyl (K)                           2           2              [14] Acetyl 
AAAAGAAAVANQGKK [14] Acetyl (K)|[15] Acetyl (K)                           2           2              [14] Acetyl 
AAFTKLDQVWGSE [5] Acetyl (K)                                              1           1              [5] Acetyl 
AAIKFIKFINPKINDGE [4] Acetyl (K)|[7] Acetyl (K)|[12] Acetyl (K)           3           3              [4] Acetyl 
AAIKFIKFINPKINDGE [4] Acetyl (K)|[7] Acetyl (K)|[12] Acetyl (K)           3           3              [4] Acetyl 
4

1 回答 1

4

试试这个方法。我对 R 不是很好,但它应该可以工作。我认为这更好地帮助而不是投票否决这个话题。

给你:

tbl_end$Seq_modif <- paste(tbl_end$Sequence, tbl_end$modifications)

tbl_end[, "Seq_modif"] <- tbl_end$Seq_modif

tbl_end <- subset(tbl_end, select = -c(Sequence,modifications) )
于 2013-10-25T11:53:41.487 回答