b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

python 安装教程 R语言脚本写作:最简单的统计与绘图,包安装、命令行参数解析、(2)

电脑杂谈  发布时间:2018-02-20 01:18:22  来源:网络整理

程序运行结果如下:

[1] "The input file is data_table.txt"[1] "The output file prefix is output"[1] "The output table is output.txt"[1] "The output figure is output.pdf"

文中把每个段落用if条件语句控制是否执行。方便读者开、关功能代码段。

用户还可根据自己的需求添加段落,再也不要为找常用语句的写法到处搜索了,有了模板,常用语句段落直接复制、修改,快速实现自己的工作!!!

模板全部代码及讲解 #!/usr/bin/env R# 1。 程序功能描述和主要步骤# 程序功能:Anova组间统计和箱线图展示# Anova functions: Calculate pvalue of groups by aov and TukeyHSD# Main steps: # - Reads data table input。txt# - Calculate pvalue and save in output。txt# - Draw boxplot and save in output。pdf# 程序使用示例# USAGE# Default# anova。r -i data_table。txt# -o otuput filename prefix for output directory name # 参数说明# Options# -i/--input 输入数据表文件 input。txt# -o/--output 输出结果文件名前缀 output_prefix, 通常会有统计表txt和矢量图pdfoptions(warn = -1)# 2。 依赖关系检查、安装和加载# See whether these packages exist on comp。

If not, install。package_list <- c("optparse","reshape2","ggplot2","ggpubr")for(p in package_list){ if(!suppressWarnings(suppressMessages(require(p, character。only = TRUE, quietly = TRUE, warn。conflicts = FALSE)))){ install。packages(p, repos="http://cran。r-project。org") suppressWarnings(suppressMessages(library(p, character。only = TRUE, quietly = TRUE, warn。conflicts = FALSE))) }}# 另两种常见R包安装方法if (FALSE){ # Bioconductor安装 source("https://bioconductor。org/biocLite。R") biocLite(c("reshape2")) # Github安装 install。

packages("devtools", repo="http://cran。us。r-project。org") library(devtools) install_github("kassambara/ggpubr")}# 清理工作环境 clean enviroment objectrm(list=ls()) # 加载依赖关系 Load essential packageslibrary(optparse)library(reshape2)library(ggplot2)library(ggpubr)# 解析命令行if (TRUE){ option_list <- list( make_option(c("-i", "--input"), type="character", default="input。txt", help="Input table file to read [default %default]"), make_option(c("-o", "--output"), type="character", default="output", help="output directory or prefix [default %default]"))opts <- parse_args(OptionParser(option_list=option_list))# 显示输入输出确认是否正确print(paste("The input file is ", opts$input, sep = ""))print(paste("The output file prefix is ", opts$output, sep = ""))}# 3。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-85745-2.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...