所以,我想合并两列。 这就是我的数据的样子:
> 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
答案 0 :(得分:6)
试试这种方式。我对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) )