Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0 2 1 #14

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TableOne"
uuid = "d36ae967-72a8-4ff4-a661-f51e671fe83a"
authors = ["Mark Pritchard <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This package is designed to summarize a dataset, for example information about p
tableone
```

## Detailed examples of useage
## Detailed examples of usage

### Mock dataset for examples

Expand Down
14 changes: 9 additions & 5 deletions src/TableOne.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Each of these must be supplied as the same type as `vars`, e.g. if `vars` is a `
a separate line with the **number (%)** in that category
* `npvars`: non-parametric variables – will display **median [1st–3rd quartiles]**
* `paramvars`: parametric variables – will display **mean (standard deviation)**
* `cramvars`: a variation on `binvars` that displays both levels in one row on the table
* `cramvars`: a variation of `binvars` that displays both levels in one row on the table

Any variables not included in one of these arguments will be presented as
`mean (standard deviation)` if the contents of the variable are
Expand All @@ -60,7 +60,6 @@ Any variables not included in one of these arguments will be presented as
Any variables not included will be listed by the column name

See documentation for examples.
```
"""
function tableone(data, strata, vars::Vector; kwargs...)
stratanames = collect(skipmissing(unique(getproperty(data, strata))))
Expand Down Expand Up @@ -582,14 +581,19 @@ function _getvarname(var, varnames::Dict)
end

function _addnmissing!(_t, varvect, strataids)
idmissing = findall(ismissing, varvect)
vectorcountmissing = findall(x -> x ∈ idmissing, strataids[:Total])
n = length(vectorcountmissing)
n = _countmissing(varvect, strataids)
nmissing = [ "" for _ ∈ axes(_t, 1) ]
nmissing[1] = sprint(show, n)
insertcols!(_t, :nmissing => nmissing)
end

function _countmissing(varvect, strataids, sn=:Total)
idmissing = findall(ismissing, varvect)
vectorcountmissing = findall(x -> x ∈ idmissing, strataids[Symbol(sn)])
n = length(vectorcountmissing)
return n
end

_binvariabledisplay(v, varvect, binvardisplay::Nothing) = maximum(skipmissing(unique(varvect)))

function _binvariabledisplay(v, varvect, binvardisplay::Dict)
Expand Down
Loading