@@ -30,7 +30,7 @@ function Base.show(io::IO, obj::Descriptive)
30
30
end
31
31
32
32
33
- function Base. getindex (a:: Descriptive , s:: Symbol ):: Real
33
+ function Base. getindex (a:: Descriptive , s:: Symbol )
34
34
return a. result[s]
35
35
end
36
36
117
117
descriptive(data;
118
118
sort::Union{Symbol, Array{T,1}} = Array{Symbol,1}(undef,0),
119
119
vars = [],
120
- stats::Union{Symbol, Array{T,1}, Tuple{Vararg{Symbol}}} = :default)::DataSet{Descriptive} where T <: Union{Symbol, String}
120
+ stats = :default)::DataSet{Descriptive} where T <: Union{Symbol, String}
121
121
122
122
Descriptive statistics.
123
123
@@ -126,9 +126,9 @@ Descriptive statistics.
126
126
- ``stats`` statistics
127
127
"""
128
128
function descriptive (data;
129
- sort:: Union{Symbol, Array{T,1 }} = Array {Symbol,1 } (undef,0 ),
129
+ sort:: Union{Symbol, Vector{T }} = Vector {Symbol} (undef,0 ),
130
130
vars = [],
131
- stats:: Union{Symbol, Array{T,1}, Tuple{Vararg{Symbol}}} = :default , level = 0.95 ):: DataSet{Descriptive} where T <: Union{Symbol, String}
131
+ stats = :default , level = 0.95 ):: DataSet{Descriptive} where T <: Union{Symbol, String}
132
132
133
133
stats = checkstats (stats)
134
134
if isa (vars, UnitRange{Int64})
@@ -181,16 +181,15 @@ function descriptive(data;
181
181
end
182
182
return DataSet (d)
183
183
end
184
- function descriptive (data:: Array{T, 1 } ; stats:: Union{Symbol, Vector, Tuple} = :default , var = nothing , varname = nothing , sort = Dict (), level = 0.95 ):: Descriptive where T <: Real
184
+ function descriptive (data:: Vector{T } ; stats = :default , var = nothing , varname = nothing , sort = Dict (), level = 0.95 ) where T <: Real
185
185
stats = checkstats (stats)
186
186
return Descriptive (var, varname, sort, descriptive_ (data, stats, level))
187
-
188
187
end
189
188
190
189
"""
191
190
Check if all statistics in allstat list. return stats tuple
192
191
"""
193
- @inline function checkstats (stats:: Union{Symbol, Array{T,1}, Tuple{Vararg{Symbol}}} ) :: Tuple{Vararg{Symbol}} where T <: Union{Symbol, String}
192
+ @inline function checkstats (stats)
194
193
allstat = (:n , :min , :max , :range , :mean , :var , :sd , :sem , :cv , :harmmean , :geomean , :geovar , :geosd , :geocv , :skew , :ses , :kurt , :sek , :uq , :median , :lq , :iqr , :mode , :meanci )
195
194
if isa (stats, Symbol)
196
195
if stats == :default stats = (:n , :mean , :sd , :sem , :uq , :median , :lq )
@@ -206,15 +205,15 @@ end
206
205
"""
207
206
Push in d Descriptive obj in mx vardata
208
207
"""
209
- @inline function pushvardescriptive! (d:: Array {Descriptive, 1 } , vars:: Array {Symbol, 1 } , mx, sortval:: Union{Tuple{Vararg{Any}}, Nothing} , stats:: Tuple{Vararg{Symbol}} ) where T <: Real
208
+ @inline function pushvardescriptive! (d:: Vector {Descriptive} , vars:: Vector {Symbol} , mx, sortval, stats)
210
209
for v = 1 : length (vars) # For each variable in list
211
210
push! (d, Descriptive (vars[v], nothing , sortval, descriptive_ (mx[:, v], stats)))
212
211
end
213
212
end
214
213
"""
215
214
Check if data row sortcol equal sortval
216
215
"""
217
- @inline function checksort (data, row:: Int , sortcol:: Array {Symbol, 1 } , sortval:: Tuple{Vararg{Any}} ) :: Bool
216
+ @inline function checksort (data, row:: Int , sortcol:: Vector {Symbol} , sortval)
218
217
for i = 1 : length (sortcol)
219
218
if data[row, sortcol[i]] != sortval[i] return false end
220
219
end
223
222
"""
224
223
Return matrix of filtered data (datacol) by sortcol with sortval
225
224
"""
226
- @inline function getsortedmatrix (data; datacol:: Array {Symbol,1 } , sortcol:: Array {Symbol,1 } , sortval:: Tuple{Vararg{Any}} )
225
+ @inline function getsortedmatrix (data; datacol:: Vector {Symbol} , sortcol:: Vector {Symbol} , sortval)
227
226
result = Array {promote_type(eltype.(data[!, c] for c in datacol)...), 1} (undef, 0 )
228
227
for c = 1 : size (data, 1 ) # For each line in data
229
228
if checksort (data, c, sortcol, sortval)
@@ -241,7 +240,7 @@ function notnan(x)
241
240
return ! (x === NaN || x === nothing || x === missing )
242
241
end
243
242
244
- @inline function descriptive_ (data:: Vector{T} , stats:: Union{Tuple{Vararg{Symbol}}, Array{Symbol,1}} , level) where T
243
+ @inline function descriptive_ (data:: Vector{T} , stats, level) where T
245
244
246
245
#=
247
246
dlist = findall(x -> x === NaN || x === nothing || x === missing, data)
275
274
276
275
277
276
278
- dict = Dict {Symbol, Real } ()
277
+ dict = Dict {Symbol, Float64 } ()
279
278
280
279
281
280
if length (data) == 0
@@ -419,10 +418,10 @@ end
419
418
return sqrt (6 * n * (n - 1 ) / ((n - 2 ) * (n + 1 ) * (n + 3 )))
420
419
end
421
420
422
- @inline function sek (data:: AbstractVector ; ses:: T = ses (data)) where T <: Real
421
+ @inline function sek (data:: AbstractVector ; ses = ses (data))
423
422
n = length (data)
424
423
sek (n; ses = ses)
425
424
end
426
- @inline function sek (n:: Int ; ses:: T = ses (n)) where T <: Real
425
+ @inline function sek (n:: Int ; ses = ses (n))
427
426
return 2 * ses * sqrt ((n * n - 1 )/ ((n - 3 ) * (n + 5 )))
428
427
end
0 commit comments