unix - Histogram frequency count for column -
i have set of data (in region of 800000 lines), in 3 columns (longitude, latitude , earthquake magnitude) not sorted in way. small example below...
-118.074 36.930 2.97 -118.005 36.898 2.61 -116.526 36.621 2.72 -116.488 36.650 2.68 -117.675 36.820 2.00 -117.963 36.514 1.30 -118.090 36.757 1.94 -117.651 36.518 1.40 -116.434 36.506 1.90 -117.914 36.531 2.10 -118.235 36.882 2.00 i required create histogram of earthquake magnitudes (in range of 1.0 7.0), not sure how go creating frequency of magnitudes.
i understand in order create histogram, need discern unique values, , set them in ascending order in column. believe can run command count function each value... need bit of in doing so!
thank can offer!
awk '{counts[$3]++} end {for (c in counts) print c, counts[c]}' inputs.txt | sort -nk2
will print unique magnitudes , counts in ascending order:
1.30 1 1.40 1 1.90 1 1.94 1 2.10 1 2.61 1 2.68 1 2.72 1 2.97 1 2.00 2
Comments
Post a Comment