Skip to content

Commit

Permalink
Merge pull request #11 from PharmCat/dev
Browse files Browse the repository at this point in the history
col names when int used
  • Loading branch information
PharmCat authored Aug 21, 2023
2 parents 4626d10 + e54dd06 commit dfb82a5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Tier1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
julia-version: [1.6, 1.7, 1.8]
julia-version: [1.6, 1.8, 1]
julia-arch: [x64]
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
Expand Down
21 changes: 16 additions & 5 deletions src/descriptive.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Import data.
"""
function dataimport(data; vars, sort = nothing)
if isa(vars, Symbol) vars = [vars] end

if eltype(vars) <: Integer vars = Tables.columnnames(data)[vars] end
if !isnothing(sort) && isa(sort, Symbol) sort = [sort] end

dataimport_(data, vars, sort)
Expand Down Expand Up @@ -157,7 +157,7 @@ function dataimport_(data, vars::AbstractVector, sort::AbstractVector)
end
return DataSet(identity.(sdata))
end
function dataimport_(data, vars, sort::Nothing)
function dataimport_(data, vars, ::Nothing)
sdata = Vector{ObsData}(undef, length(vars))
for i in 1:length(vars)
sdata[i] = ObsData(Tables.getcolumn(data, vars[i]), vars[i], Dict(:Variable=>vars[i]))
Expand Down Expand Up @@ -209,6 +209,7 @@ function descriptives(data, vars, sort = nothing; kwargs...)
if isa(vars, Symbol) vars = [vars] end
if isa(sort, String) sort = [Symbol(sort)] end
if isa(sort, Symbol) sort = [sort] end
if eltype(vars) <: Integer vars = Tables.columnnames(data)[vars] end
if !isnothing(sort)
vars = setdiff(vars, sort)
end
Expand All @@ -228,6 +229,7 @@ function descriptives(data; vars = nothing, sort = nothing, kwargs...)
end
if length(vars) == 0 error("No column found for descriptive statistics!") end
end
if eltype(vars) <: Integer vars = Tables.columnnames(data)[vars] end
descriptives(data, vars, sort; kwargs...)
end
"""
Expand Down Expand Up @@ -475,7 +477,7 @@ end
#
################################################################################

function MetidaBase.metida_table(obj::DataSet{DS}; sort = STATLIST, stats = nothing, id = nothing) where DS <: Descriptives
function MetidaBase.metida_table(obj::DataSet{DS}; sort = nothing, stats = nothing, id = nothing) where DS <: Descriptives
idset = Set(keys(first(obj).data.id))
resset = Set(keys(first(obj).result))
if length(obj) > 1
Expand All @@ -484,12 +486,21 @@ function MetidaBase.metida_table(obj::DataSet{DS}; sort = STATLIST, stats = noth
union!(resset, Set(keys(obj[i].result)))
end
end

if !isnothing(stats)
stats STATLIST || error("Some statistics not known!")
if isa(stats, Symbol) stats = [stats] end
ressetl = sortbyvec!(collect(intersect(resset, stats)), sort)
if isnothing(sort)
ressetl = collect(intersect(resset, stats))
else
ressetl = sortbyvec!(collect(intersect(resset, stats)), sort)
end
else
ressetl = sortbyvec!(collect(resset), sort)
if isnothing(sort)
ressetl = collect(resset)
else
ressetl = sortbyvec!(collect(resset), sort)
end
end
if !isnothing(id)
if isa(id, Symbol) id = [id] end
Expand Down

2 comments on commit dfb82a5

@PharmCat
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/90053

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" dfb82a51915e063d4cef9f43964ec3428d1fd3b7
git push origin v0.2.0

Please sign in to comment.