将多个文本文档合并成一个excel 文件(多sheet)

2021-11-12  本文已影响0人  bioYIYI

实例:

Rscript  format.r <indir> <outdir> <outfile>

代码:

基本思路是这样,下面是个简单的临时使用的脚本,可根据自己的需求自行修改,format.r:

args = commandArgs(T)
if (length(args) !=3){
    print("Rscript this R <indir> <outdir> <outfile>")
    q()
}
library(openxlsx)
single<-read.table(paste(args[1],"/single_shannon.xls",sep=""),header=T,sep="\t")
pair<-read.table(paste(args[1],"/pair_shannon.xls",sep=""),header=T,sep="\t")
S_C<-read.table(paste(args[1],"/danyangbenbijiao.xls",sep=""),header=T,sep="\t")
M_C<-read.table(paste(args[1],"/hunheyangbenbijiao.xls",sep=""),header=T,sep="\t")
delta_M<-read.table(paste(args[1],"/delta_shannon_mixture.xls",sep=""),header=T,sep="\t")
delta_P<-read.table(paste(args[1],"/delta_shannon_patient.xls",sep=""),header=T,sep="\t")
sheets = list("shannon-pair" = pair,"shannon-single" = single,"单个样本熵值比较" = S_C,"混合样本熵值比较" = M_C,"混合样本熵差比较" = delta_M, "患者特征值比较"=delta_P)
write.xlsx(sheets,paste(args[2],"/",args[3],sep=""))
上一篇 下一篇

猜你喜欢

热点阅读