美文网首页
R语言交补集数据处理

R语言交补集数据处理

作者: ShanSly | 来源:发表于2021-08-27 08:19 被阅读0次

    一、交集——Merge函数

    rm(list = ls())
    setwd('/lab412C/LSM/蛋白质谱/蛋白质谱-RNA seq/缺少的300个')
    data1 <- read.csv(file = "all.csv",header = T,sep = ",")
    data2 <- read.csv(file = "deg.csv",header = T,sep = ",")
    data3 <- merge(data1,data2,by.X='gene')
    data3=data3[!duplicated(data3),] ##删除重复行
    write.csv(data3, quote = F,file='/lab412C/LSM/蛋白质谱/蛋白质谱-RNA seq/DEG-Map88个.csv')
    

    二、补集——sqldf函数

    rm(list = ls())
    library(sqldf)
    setwd('/lab412C/LSM/蛋白质谱/蛋白质谱-RNA seq/缺少的300个')
    my.dataset <- data1 <- read.csv(file = "all.csv",header = T,sep = ",")
    my.dataset1 <- data2 <- read.csv(file = "deg.csv",header = T,sep = ",")
    data3 <- sqldf('SELECT * FROM [my.dataset] EXCEPT SELECT * FROM [my.dataset1]')
    write.csv(data3, quote = F,file='/lab412C/LSM/蛋白质谱/蛋白质谱-RNA seq/DEG-Map88个.csv')
    

    前提:输入数据的两列必须完全一致!

    相关文章

      网友评论

          本文标题:R语言交补集数据处理

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