A summary command for statistics
Even if there wasn't one, there is one now: I think you've just written it yourself :-)
summary[dset_] := Through[{Min, Quantile[#, .25] &, Median, Quantile[#, .75] &, Max}[dset]]
SeedRandom[1234]
data = RandomInteger[{0, 100}, 100];
summary[data]
(* Out: {0, 18, 91/2, 66, 98} *)
On 2019-10-02 the resource function "RecordsSummary" was published at the Wolfram Function Repository.
Here is usage example (from the resource function page):
Block[{n = 200},
arr = Flatten /@
Transpose[{RandomReal[{-10, 10}, {n, 2}],
MapAt[ToLowerCase,
RandomChoice[CharacterRange["A", "Z"], {n, 2}], {All, 2}],
RandomChoice[{E, I, \[CapitalGamma]}, n]}]];
ResourceFunction["RecordsSummary"][arr]
First answer (2016-02-25)
Some time ago I programmed such a function, RecordsSummary
, inspired by R's summary
. Here is an example of its usage: Census data summary .
As the name implies, it is assumed that we have a list of records, all with the same length, and we want the columns to be summarized. (Each record is a row.)
You can get the package MathematicaForPredictionUtilities.m from MathematicaForPrediction at GitHub or simply run this command:
Import["https://raw.githubusercontent.com/antononcube/MathematicaForPrediction/master/MathematicaForPredictionUtilities.m"]
Let us create random data.
data = RandomInteger[{0, 100}, 100];
dataCat = RandomChoice[Characters["azbuka"], 100];
data2 = RandomInteger[{0, 100}, {100, 4}];
Here are examples of using RecordsSummary over the created data.
1. Call on a 1D array:
RecordsSummary[ data ]
2. Summary of a 2D numeric array. The columns are named automatically.
RecordsSummary[N[data2]]
3. Fancy output of numerical and categorical data summary. The column names are the second argument given to RecordsSummary.
Grid[{RecordsSummary[
Transpose[{N[data], dataCat}], {"Numeric", "Categorical"}]},
Alignment -> Top, Dividers -> All]