我有一个包含8个变量的表,我想合并2个名为Sample和NorTum的列,并且Sample和NorTum这两列应保留在表中。有人知道如何用R或SQL做到这一点?数据如下:
Sample Sample_Code Sample_Group NorTum Sentrix_ID Sentrix_Position Pool_ID Folderdate
1 00_11242 00_11242T1 MUTYH T1 1403371 R007_C006 GS0005703-OPA Exp051118
2 00_11242 00_11242T1 MUTYH T1 1403371 R007_C012 GS0005704-OPA Exp051118
3 00_11242 00_11242T1 MUTYH T1 1416198 R007_C006 GS0005701-OPA Exp051118
4 00_11242 00_11242T1 MUTYH T1 1416198 R007_C012 GS0005702-OPA Exp051118
5 00_11242 00_11242T1 MUTYH T1 1280307 R007_C006 GS0005703-OPA Exp051116
6 00_11242 00_11242T1 MUTYH T1 1280307 R007_C012 GS0005704-OPA Exp051116
7 00_11242 00_24200N2 MUTYH N 1403371 R007_C005 GS0005703-OPA Exp051118
8 00_11242 00_24200N2 MUTYH N 1403371 R007_C011 GS0005704-OPA Exp051118
我很抱歉桌子格式不好。但是,例如:示例:00_11242和Nortum:T1合并到Sample_ID,以便输出如下所示:Sample_ID:00_11242_T1
提前致谢!
答案 0 :(得分:3)
假设您的数据帧名为dat
dat$Sample_ID <- paste(dat$Sample, dat$NorTum, sep = "_")