美文网首页
R语言--常用但总记不住的数据处理小技巧

R语言--常用但总记不住的数据处理小技巧

作者: JL笔记 | 来源:发表于2021-10-31 18:11 被阅读0次

    ##提取列表中包含特定字符的元素

    DE.pattern = your_list[grep(pattern = "pattern",x = names(your_list),value = T)]

    ##批量读取列表内文件名字

    library(pipeR)

    library(rlist)

    test = list.files(path = "E:/Desktop/",pattern = "*" )

    write.table(test,"E:/Desktop/readme.xls",sep = "\t")

    ###读取Excel中所有sheet

    library(readxl)

    excel_path <- c("your path/附件1植物激素MRM定量分析结果-1读取.xlsx")

    data = list()

    for (i in 1:length(excel_sheets(excel_path))) {

      data[[i]] = read_xlsx(path = excel_path,sheet = i)

    }

    names(data) = excel_sheets(excel_path)

    ###替换掉数据中的inf/NA/0

    yourdata[yourdata==Inf]<-NA

    ###绘制热图时去掉所有值行为0的行

    data_figure = data_figure[which(rowSums(data_figure)>0),]

    相关文章

      网友评论

          本文标题:R语言--常用但总记不住的数据处理小技巧

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