Skip to content

Instantly share code, notes, and snippets.

@aabiddanda
Last active February 8, 2016 23:05
Show Gist options
  • Save aabiddanda/c4ecc4ce9b995aee3b5c to your computer and use it in GitHub Desktop.
Save aabiddanda/c4ecc4ce9b995aee3b5c to your computer and use it in GitHub Desktop.
Summary Stats in the Terminal
#Usage : <file> <column>
mawk_stats(){
file=$1
col=$2
mawk -v c=$col '{if(min==""){min=max=$c};
if($c > max){max=$c}; if($c < min){min=$c}; sum+=$c; n+=1}
END {printf "Min\tMax\tMean\tN\n%.3f\t%.3f\t%.3f\t%.0f\n",min, max ,sum/n, n}' $file
}
#Usage : <file> <column>
rsummary(){
R --vanilla --slave -e 'library(data.table); t <- fread("'$1'"); summary(t$V'$2')'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment