Created
September 30, 2012 17:26
-
-
Save andrewvc/3807772 to your computer and use it in GitHub Desktop.
Thinking Stats first exercise, using shell instead of python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
split_cmd='cut -b 275,276,277,278,279 2002FemPreg.dat' | |
first_avg=`$split_cmd | grep '1 1$' | cut -b 1,2 | awk '{s += $1} END { print s/NR }'` | |
other_avg=`$split_cmd | grep -v ' 1$' | grep '1..$' | cut -b 1,2 | awk '{s += $1} END { print s/NR }'` | |
hours_diff=`echo "($first_avg-$other_avg)*168" | bc` | |
echo First borns: $first_avg weeks | |
echo Non-first borns: $other_avg weeks | |
echo Difference: $hours_diff hours |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment