Split to the column data R

Transfer: https://mp.weixin.qq.com/s/tuEuAJr3MJ-M5BFr70CJbA

Question: According to the second column after the semicolon separator split into four

options(stringsAsFactors = F)

a=data.frame(x=c('A','B','C'),
             y=c('TP53','KCNMA1;RP11-443A13.5','BRCA1'))
a
do.call(rbind,lapply(1:nrow(a), function(i){
  x=as.character(a[i,])
  return(data.frame(sample=x[1],
                    gene=unlist(strsplit(x[2],";")[[1]])))
}))

Guess you like

Origin www.cnblogs.com/yuwq/p/11570391.html