将多行分散为一列?

时间:2019-09-30 00:47:03

标签: r

我有一个df:

start<-c("123337543","123337543","68947241","68947241")
stop<-c("123338361","123338361","68954945","68954945")
snp<-c("chr8_94225198_G_A_b38","chr8_94225198_G_A_b38","chr3_123338356_C_A_b38","chr3_123338356_C_A_b38")
tissue<-c("Thyroid","Esophagus","Esophagus","Thyroid")
df<-data.frame(start,stop,snp,tissue)

是否存在将行“合并”为一列的方法? 例如,结果将如下所示:

start<-c("123337543","123337543")
stop<-c("123338361","123338361")
snp<-c("chr8_94225198_G_A_b38","chr3_123338356_C_A_b38")
tissue<-c("Thyroid,Esophagus","Thyroid,Esophagus")
df<-data.frame(start,stop,snp,tissue)

我尝试了dplyr spread和group_by,但由于没有唯一值,我认为我遇到了麻烦?

0 个答案:

没有答案