|||
有时,在Linux命令行环境下产生一列数值数据,想知道这列数据的最大值、最小值、和、平均值等参数。对于这个问题,有很多种解决方案,比如把数据拷贝或下载到Excel中,然后利用Excel或SAS、SPSS等专业的统计软件的强大功能来计算,也可以写一个简单的Perl脚本计算,或者把数据导入到R交互环境中计算,或者写一个awk代码。但显然,这些方案都比较费事。今天在一个群里看到有人提到datamash,检索发现确实是一个实现这一功能的很好的工具,于是把收集到的一些资料在此整理介绍。
datamash又称GNU datamash,是GNU工程下的一个程序,其主页面的介绍是:GNU datamash is a command-line program which performs basic numeric, textual and statistical operations on input textual data files (GNU datamash 是一个在输入文本数据文件时做基础数字、文本和统计操作的命令行程序)。
这是一个计算数值1到10的加合和平均值的例子:
$ seq 10 | datamash sum 1 mean 1
155 5.5
GNU datamash几乎支持所有的平台,包括大部分的UNIX,Windows和Mac OS,这里是软件安装方法:download section。
Documentation and Help
Usage Examples
Alternative one-liners and more examples
Online Datamash Manual
Brief help screen: datamash --help
Usage details and examples: man datamash
For the complete manual in info format run: info datamash
Please send questions, suggestions, patches and bug reports to bug-datamash@gnu.org
Searchable archive of questions and discussions at: http://lists.gnu.org/archive/html/bug-datamash/ .
Subscribe at: https://lists.gnu.org/mailman/listinfo/bug-datamash
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2025-3-20 00:05
Powered by ScienceNet.cn
Copyright © 2007-2025 中国科学报社