GNU datamash - alternative one-liners

GNU datamash is designed for ease of use, strict input validation,
and robust operation.
If datamash is not available, some operations could be performed using
existing software (such as awk, Perl,
R).
Using Datamash has the following advantages over simple one-liners:

Datamash operations are simpler to type, and less error-prone than
writing one-liners.

Datamash supports header lines (-H/--headers) on
all operations.

Datamash supports printing the entire line (-f/--full), not
just the field being processed.

Datamash's output is suitable for both interactive command-line usage, and
for scripting, automation and down-stream processing by other tools.

When analysis requires more than basic operations provided by GNU Datamash,
users will benefit from switching to GNU R,
GNU PSPP,
GNU Octave, or other programming
languages.
If you have suggestions and/or improvement to the one-liner examples below,
please send them to bug-datamash@gnu.org.

sum, min, max, mean (single field, without grouping)

Calculating the sum, minimum value, maximum value and mean can be achieved
with awk:

first, last, count, rand, unique, collapse (with grouping)

awk and Perl can be used to perform equivalent
Datamash operations, such as calculating the sum, minimum value, maximum value,
unique values of groupped input data.
The following input will be used for the examples below. It simulates input
data with two groups (a, b) and multiple values in
each group:

The awk and Perl versions has the advantage of not
need to sort the input, at the expense of using more memory.
However, using Perl one-liners without additional code does not handle I/O
errors, such as:

GNU R's output formatting is preferable for interactive exploration of data.
Datamash's output is preferable for scripting and automation.
Similar to Perl one-liners, GNU R will not detect I/O
errors without additional code. For scripting and automation,
Datamash's error reporting is more informative: