From 442684a5b6f826be03598df8a0ce9be1341fcab2 Mon Sep 17 00:00:00 2001 From: Josh <91748819+JoshKImperial@users.noreply.github.com> Date: Thu, 17 Mar 2022 11:14:39 +0000 Subject: [PATCH] Allow for describe to operate over an entire Matrix --- src/scalarstats.jl | 1 + test/misc.jl | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/scalarstats.jl b/src/scalarstats.jl index 993c8da6b..3878045a1 100644 --- a/src/scalarstats.jl +++ b/src/scalarstats.jl @@ -897,6 +897,7 @@ median, 75th percentile, and maxmimum. function summarystats(a::AbstractArray{T}) where T<:Union{Real,Missing} # `mean` doesn't fail on empty input but rather returns `NaN`, so we can use the # return type to populate the `SummaryStats` structure. + a = length(size(a)) != 1 ? a[:] : a s = T >: Missing ? collect(skipmissing(a)) : a m = mean(s) R = typeof(m) diff --git a/test/misc.jl b/test/misc.jl index 63fc24df9..b4006fa87 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -90,3 +90,16 @@ describe(io, fill("s", 3)) Type: String Number Unique: 1 """ +describe(io, reshape(collect(1:100), (10, 10))) +@test String(take!(io)) == """ + Summary Stats: + Length: 100 + Missing Count: 0 + Mean: 50.500000 + Minimum: 1.000000 + 1st Quartile: 25.750000 + Median: 50.500000 + 3rd Quartile: 75.250000 + Maximum: 100.000000 + Type: $Int + """ \ No newline at end of file