Reputation: 102
So, I'd like to merge two columns in one. That's how my data looks like:
> 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
I'd like to merge columns Sequence and modifications without disturbing other dataset.
The name of new column may be "Seq_modif"
Tried to do it with paste but it's not what I am looking for:
tbl_reo2 <- paste(tbl_end$Sequence,tbl_end$modifications)
so that's what I'd like to achieve by the script:
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
Upvotes: 1
Views: 11803
Reputation: 1120
Try this way. I'm not so good with R but it should work. I think that's better to help instead of vote the topic down.
Here you are:
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) )
Upvotes: 4