update histogram, nth documentation

This commit is contained in:
Sebastian Jung
2019-11-28 19:32:31 +01:00
committed by Yehuda Katz
parent 5406450c42
commit 7db3c69984
2 changed files with 64 additions and 145 deletions

View File

@ -17,156 +17,64 @@ Let's say we have this file `random_numers.csv` which contains 50 random numbers
```shell ```shell
> open random_numbers.csv > open random_numbers.csv
━━━━┯━━━━━━━━━━━━━━━ open random_numbers2.csv
# │ random number ━━━━┯━━━━━━━━━━━━━━━━
────┼─────────────── # │ random numbers
087 ────┼────────────────
146 00
239 15
25
... ...
470
4794 482
4861 494
4967 ━━━━┷━━━━━━━━━━━━━━━━
━━━━┷━━━━━━━━━━━━━━━
``` ```
If we now want to see how often the different numbers were generated, we can use the `histogram` function: If we now want to see how often the different numbers were generated, we can use the `histogram` function:
```shell ```shell
> open random_numbers.csv | histogram "random number" > open random_numbers2.csv | histogram "random numbers"
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ random number │ frecuency # │ random numbers │ frequency
───┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
010 │ ************************* 00 │ ****************************************************************************************************
114 │ ************************************************** 11 │ ******************************
217 │ ************************* 22 │ *************************************************************
322 │ ************************* 33 │ *********************************************************************
424 │ ************************* 44 │ *****************************************************
528 │ ************************* 55 │ *********************************************************************
629 │ ************************* ━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
731 │ *************************
837 │ *************************
938 │ *************************
1039 │ *************************
1145 │ *************************
1246 │ ***************************************************************************
1349 │ *************************
145 │ *************************
1551 │ ***************************************************************************
1652 │ *************************
1755 │ *************************
1856 │ **************************************************
1960 │ *************************
2061 │ **************************************************
2164 │ *************************
2265 │ *************************
2367 │ **************************************************
2468 │ *************************
2573 │ *************************
2680 │ **************************************************
2782 │ *************************
2886 │ ****************************************************************************************************
2987 │ **************************************************
3088 │ *************************
3189 │ *************************
329 │ *************************
3392 │ *************************
3494 │ *************************
3596 │ *************************
3699 │ *************************
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
``` ```
We can also set the name of the second column or sort the table: We can also set the name of the second column or sort the table:
```shell ```shell
> open random_numbers.csv | histogram "random number" probability > open random_numbers2.csv | histogram "random numbers" probability
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ random number │ probability # │ random numbers │ probability
───┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
010 │ ************************* 00 │ ****************************************************************************************************
114 │ ************************************************** 11 │ ******************************
217 │ ************************* 22 │ *************************************************************
322 │ ************************* 33 │ *********************************************************************
424 │ ************************* 44 │ *****************************************************
528 │ ************************* 55 │ *********************************************************************
629 │ ************************* ━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
731 │ *************************
837 │ *************************
938 │ *************************
1039 │ *************************
1145 │ *************************
1246 │ ***************************************************************************
1349 │ *************************
145 │ *************************
1551 │ ***************************************************************************
1652 │ *************************
1755 │ *************************
1856 │ **************************************************
1960 │ *************************
2061 │ **************************************************
2164 │ *************************
2265 │ *************************
2367 │ **************************************************
2468 │ *************************
2573 │ *************************
2680 │ **************************************************
2782 │ *************************
2886 │ ****************************************************************************************************
2987 │ **************************************************
3088 │ *************************
3189 │ *************************
329 │ *************************
3392 │ *************************
3494 │ *************************
3596 │ *************************
3699 │ *************************
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
``` ```
```shell ```shell
> open random_numbers.csv | histogram "random number" probability | sort-by probability > open random_numbers2.csv | histogram "random numbers" probability | sort-by probability
━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# │ random number │ probability # │ random numbers │ probability
───┼───────────────┼────────────────────────────────────────────────────────────────────────────────────────────────────── ───┼───────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
010 │ ************************* 01 │ ******************************
117 │ ************************* 14 │ *****************************************************
222 │ ************************* 22 │ *************************************************************
324 │ ************************* 33 │ *********************************************************************
428 │ ************************* 45 │ *********************************************************************
529 │ ************************* 50 │ ****************************************************************************************************
631 │ ************************* ━━━┷━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
737 │ *************************
838 │ *************************
939 │ *************************
1045 │ *************************
1149 │ *************************
125 │ *************************
1352 │ *************************
1455 │ *************************
1560 │ *************************
1664 │ *************************
1765 │ *************************
1868 │ *************************
1973 │ *************************
2082 │ *************************
2188 │ *************************
2289 │ *************************
239 │ *************************
2492 │ *************************
2594 │ *************************
2696 │ *************************
2799 │ *************************
2814 │ **************************************************
2956 │ **************************************************
3061 │ **************************************************
3167 │ **************************************************
3280 │ **************************************************
3387 │ **************************************************
3446 │ ***************************************************************************
3551 │ ***************************************************************************
3686 │ ****************************************************************************************************
━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
``` ```

View File

@ -3,10 +3,13 @@
This command returns the nth row of a table, starting from 0. This command returns the nth row of a table, starting from 0.
If the number given is less than 0 or more than the number of rows, nothing is returned. If the number given is less than 0 or more than the number of rows, nothing is returned.
## Usage ### Usage
```shell ```shell
> [input-command] | nth [row-number] > [input-command] | nth <row number> ...args
``` ```
### Parameters:
* `<row number>` the number of the row to return
* `args`: Optionally return more rows
## Examples ## Examples
```shell ```shell
@ -21,11 +24,19 @@ If the number given is less than 0 or more than the number of rows, nothing is r
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ ━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
> ls | nth 0 > ls | nth 0
━━━━━━━━━━━━┯━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━ ━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
name │ typereadonly │ size │ accessed │ modified # │ name │ type │ readonly │ size │ accessed │ modified
────────────┼──────┼──────────┼────────┼───────────────┼─────────────── ───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago 0 Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
━━━━━━━━━━━━┷━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━ ━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
> ls | nth 0 2
━━━┯━━━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━
# │ name │ type │ readonly │ size │ accessed │ modified
───┼────────────┼───────────┼──────────┼────────┼───────────────┼───────────────
0 │ Cargo.toml │ File │ │ 239 B │ 2 minutes ago │ 2 minutes ago
2 │ .gitignore │ File │ │ 19 B │ 2 minutes ago │ 2 minutes ago
━━━┷━━━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━
> ls | nth 5 > ls | nth 5
``` ```