# lazyopt **Repository Path**: mloine/lazyopt ## Basic Information - **Project Name**: lazyopt - **Description**: R包。简化R语言读取参数,自动处理读取的参数格式。并且自动完成-help 和缺少参数的一些提示功能,不需要开发人员关心。 - **Primary Language**: R - **License**: MulanPSL-1.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-07 - **Last Updated**: 2022-07-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # lazyopt **介绍** 简化R语言读取参数,自动处理读取的参数格式。并且自动完成-help 和缺少参数的一些提示功能,不需要开发人员关心。 **安装教程** git clone https://gitee.com/mloine/lazyopt.git R CMD build ./ R install.packages("./lazyopt_2.0.tar.gz") **使用说明** 主函数:lazyopt(spec,arg=NULL) **例子** ``` arg <- c("-i", "E:/projects/Lysimeter_Systems/src/output/A13.xls", "-o", "E:/projects/Lysimeter_Systems/src/image2") opt <- matrix(c( "inputfile", "i", 2, "character", "Set the input file path or packagepath", " ", "outputpackage", "o", 2, "character", "Set the output folder path", " ", "resolution", "dpi", 1, "numeric", "Set the resolution to allow 72,96,300 or 600", "300" ), byrow = TRUE, ncol = 6) %>% lazyopt(arg=arg) print(opt$inputfile) print(opt$outputpackage) print(opt$resolution) ``` ############################################################################### [1] "E:/projects/Lysimeter_Systems/src/output/A13.xls" [1] "E:/projects/Lysimeter_Systems/src/image2" [1] 300 ############################################################################### spec 是一个6列的矩阵 每一行是一个参数的设置 "inputfile", "i", 2, "character", "Set the input file path or packagepath", " ", 第一列:长参数 --inputfile 第二列:短参数 -i (不限字符串长度) 第三列:参数必要性 2参数必须要填,1可选 第四列:参数数据类型 numeric,logical,character 第五列:参数说明 第六列:默认值 会根据参数类型做转换 **参数说明** arg参数,默认是NULL。 开发者可以设置arg参数来模拟用户输入的参数便于开发测试。 实际使用效果(默认arg=NULL) ############################################################################## ![输入图片说明](https://images.gitee.com/uploads/images/2020/1021/104524_2a504564_5401622.png "屏幕截图.png")