Update histogram examples

This commit is contained in:
Joseph T Lyons
2020-08-15 01:31:17 -04:00
committed by Andrés N. Robalino
parent d1d98a897a
commit 8f00713ad2
2 changed files with 64 additions and 64 deletions

View File

@ -20,13 +20,13 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers
────┬────────────────
# │ random numbers
────┼────────────────
01
05
12
22
20
...
475
485
491
471
481
492
────┴────────────────
```
@ -34,59 +34,59 @@ If we now want to see how often the different numbers were generated, we can use
```shell
> open random_numbers.csv | histogram "random numbers"
───┬────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ frequency
───┼────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001******
1115 │ ****************************************************************************************************
2210 │ ******************************************************************
337 │ **********************************************
449 │ ************************************************************
558*****************************************************
───┴────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ occurrences │ percentage │ frequency
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
00 8 │ 57.14% │ *********************************************************
11 14 │ 100.00% │ ****************************************************************************************************
22 9 │ 64.29% │ ****************************************************************
33 6 │ 42.86% │ ******************************************
44 3 │ 21.43% │ *********************
55 10 │ 71.43% │ ***********************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
We can also set the name of the second column or sort the table:
```shell
> open random_numbers.csv | histogram "random numbers" probability
───┬────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ probability
───┼────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001******
1115 │ ****************************************************************************************************
2210 │ ******************************************************************
337 │ **********************************************
449 │ ************************************************************
558*****************************************************
───┴────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ occurrences │ percentage │ probability
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
00 8 │ 57.14% │ *********************************************************
11 14 │ 100.00% │ ****************************************************************************************************
22 9 │ 64.29% │ ****************************************************************
33 6 │ 42.86% │ ******************************************
44 3 │ 21.43% │ *********************
55 10 │ 71.43% │ ***********************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
```shell
> open random_numbers.csv | histogram "random numbers" probability | sort-by probability
───┬────────────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ count │ probability
───┼────────────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
001******
137 │ **********************************************
258*****************************************************
349************************************************************
4210 │ ******************************************************************
5115 │ ****************************************************************************************************
───┴────────────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
───┬────────────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ random numbers │ occurrences │ percentage │ probability
───┼────────────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
04 3 │ 21.43% │ *********************
13 6 │ 42.86% │ ******************************************
20 8 │ 57.14% │ *********************************************************
32 9 │ 64.29% │ ****************************************************************
45 1071.43% │ ***********************************************************************
51 14 │ 100.00% │ ****************************************************************************************************
───┴────────────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```
Of course, histogram operations are not restricted to just analyzing numbers in files, you can also analyze your directories
```shell
> ls -la | histogram type | sort-by count
───┬─────────┬───────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ type │ count │ frequency
───┼─────────┼───────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0Symlink │ 8 │ *****************
1File 9 │ ********************
2Dir 45 │ ****************************************************************************************************
───┴─────────┴───────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
> ls -la | histogram type | sort-by occurrences
───┬─────────┬─────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────
# │ type │ occurrences │ percentage │ frequency
───┼─────────┼─────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
0Dir │ 5 │ 4.76% │ ****
1Symlink │ 2826.67% │ **************************
2File 105 │ 100.00% │ ****************************************************************************************************
───┴─────────┴─────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────
```