-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from PharmCat/dev
gha upd
- Loading branch information
Showing
6 changed files
with
73 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "MetidaFreq" | ||
uuid = "bd16ee1e-1b2f-4f89-b253-604a522f8c5f" | ||
authors = ["PharmCat <[email protected]>"] | ||
version = "0.1.5" | ||
version = "0.2.0" | ||
|
||
[deps] | ||
|
||
|
@@ -18,11 +18,11 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | |
[compat] | ||
|
||
CategoricalArrays = "0.8, 0.9, 0.10" | ||
Distributions = "0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25" | ||
Distributions = "0.20, 0.21, 0.22, 0.23, 0.24, 0.25" | ||
HypothesisTests = "0.10, 0.11" | ||
MetidaBase = "0.11, 0.12" | ||
Optim = "1" | ||
Roots = "1, 2" | ||
Roots = "2" | ||
StatsBase = "0.30, 0.31, 0.32, 0.33, 0.34" | ||
Tables = "1" | ||
julia = "1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,51 @@ | ||
|
||
""" | ||
freq(data, col; id = Dict()) | ||
freqdict(data::AbstractVector) | ||
Return frequencies as `Dict`. | ||
""" | ||
function freq(data, col; id = Dict()) | ||
if isa(col, String) cols = Symbol(col) else cols = col end | ||
column = Tables.getcolumn(data, cols) | ||
d = Dict{eltype(column), Int}() | ||
for i in column | ||
function freqdict(data::AbstractVector) | ||
d = Dict{eltype(data), Int}() | ||
for i in data | ||
ind = ht_keyindex(d, i) | ||
if ind > 0 | ||
@inbounds d.vals[ind] += one(Int) | ||
else | ||
@inbounds d[i] = one(Int) | ||
end | ||
end | ||
d | ||
end | ||
|
||
""" | ||
freq(data, col; id = Dict()) | ||
Return frequencies as ix1 contingency table. | ||
""" | ||
function freq(data, col; id = Dict()) | ||
if isa(col, String) cols = Symbol(col) else cols = col end | ||
column = Tables.getcolumn(data, cols) | ||
d = freqdict(column) | ||
k = collect(keys(d)) | ||
mx = Matrix{Int}(undef, 1, length(k)) | ||
mx = Matrix{Int}(undef, length(k), 1 ) | ||
for i = 1:length(k) | ||
@inbounds mx[1, i] = d[k[i]] | ||
@inbounds mx[i, 1] = d[k[i]] | ||
end | ||
ConTab(mx, [string(col)], string.(k), id) | ||
ConTab(mx, string.(k), [string(col)], id) | ||
end | ||
|
||
""" | ||
freq(data::AbstractVector; id = Dict()) | ||
Return frequencies as ix1 contingency table. | ||
""" | ||
function freq(data::AbstractVector; id = Dict()) | ||
d = freqdict(data) | ||
k = collect(keys(d)) | ||
mx = Matrix{Int}(undef, length(k), 1) | ||
for i = 1:length(k) | ||
@inbounds mx[i, 1] = d[k[i]] | ||
end | ||
ConTab(mx, string.(k), [""], id) | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters