zoukankan      html  css  js  c++  java
  • R脚本中使用命令行 进行传参

    1、

    root@PC1:/home/test# cat test.r
    library(optparse)
    
    option_list <- list(
      make_option(c("-p", "--arg1"), type = "character", default=FALSE),
      make_option(c("-q", "--arg2"), type = "character", default=FALSE),
      make_option(c("-m", "--arg3"), type = "character", default=FALSE)
    )
    opt_parser = OptionParser(option_list=option_list);
    opt = parse_args(opt_parser);
    
    file1 = read.table(opt$arg1,header = F)
    file2 = read.table(opt$arg2,header = F)
    file3 = read.table(opt$arg3,header = F)
    
    file4 = rbind(file3, file2, file1)
    
    write.table(file4, "x.csv", row.names = F, col.names = F, sep = "\t")
    root@PC1:/home/test# cat a.txt
    1       1       1
    1       1       1
    root@PC1:/home/test# cat b.txt
    2       2       2
    2       2       2
    root@PC1:/home/test# cat c.txt
    3       3       3
    3       3       3

    2、测试运行

    root@PC1:/home/test# Rscript test.r --arg1 a.txt --arg2 b.txt --arg3 c.txt
    root@PC1:/home/test# ls
    a.txt  b.txt  c.txt  test.r  x.csv
    root@PC1:/home/test# cat x.csv
    3       3       3
    3       3       3
    2       2       2
    2       2       2
    1       1       1
    1       1       1
  • 相关阅读:
    总结
    设置导航栏上面的内容
    统一所有控制器导航栏左上角和右上角内容
    直接设置UIView的x,y,width,height...
    block浅析
    const浅析
    - (BOOL)isEqual:(id)object
    数据存入沙盒
    swift感悟2
    swift自学感悟1
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/15449693.html
Copyright © 2011-2022 走看看