美文网首页
2022-02-02 R语言-一行拆分成多行

2022-02-02 R语言-一行拆分成多行

作者: NAome | 来源:发表于2022-02-02 18:22 被阅读0次

  将一个单元格中的多个元素拆分成多行,如图。


一行拆分成多行
#示例代码
df <- data.frame(gene_ID=c("ENSG00000223972.5","ENSG00000243485.5"),
                 transcript_ID=c("ENST00000456328.2,ENST00000450305.2","ENST00000473358.1,ENST00000469289.1"))

library(tidyr)

df2 <-df %>% as_tibble() %>% 
  separate_rows(transcript_ID, sep = ",")

相关文章

网友评论

      本文标题:2022-02-02 R语言-一行拆分成多行

      本文链接:https://www.haomeiwen.com/subject/dzsrkrtx.html