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

Iuliadmtru/exampledocs #16

Merged
merged 4 commits into from
Jul 18, 2022
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
26 changes: 2 additions & 24 deletions docs/src/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,6 @@

The following examples use the Academic Performance Index (API) dataset for Californian schools.

## Julia code

```julia
using Survey

data(api)
dclus1 = svydesign(id = :1, weights = :pw, data = apiclus1)
svyby(:api00, :cname, dclus1, svymean)

11×3 DataFrame
Row │ cname mean SE
│ String15 Float64 Float64
─────┼────────────────────────────────
1 │ Alameda 669.0 16.2135
2 │ Fresno 472.0 9.85278
3 │ Kern 452.5 29.5049
4 │ Los Angeles 647.267 23.5116
5 │ Mendocino 623.25 24.216
6 │ Merced 519.25 10.4925
7 │ Orange 710.562 28.9123
8 │ Plumas 709.556 13.2174
9 │ San Diego 659.436 12.2082
10 │ San Joaquin 551.189 11.578
11 │ Santa Clara 732.077 12.2291
```@docs
svyby(formula::Symbol, by, design::svydesign, func::Function, params = [])
```
4 changes: 1 addition & 3 deletions src/svyby.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ svytotal = function(x, w, popsize, sampsize)
end

"""
The `svyby` function can be used to generate stratified estimates.
The `svyby` function can be used to generate subsets of a survey design.

```jldoctest
julia> using Survey
Expand All @@ -48,8 +48,6 @@ julia> svyby(:api00, :cname, dclus1, svymean)
10 │ San Joaquin 551.189 11.578
11 │ Santa Clara 732.077 12.2291
```

julia> svyby(:api00, [:cname, :meals], dclus1, svymean);
"""
function svyby(formula::Symbol, by, design::svydesign, func::Function, params = [])
gdf = groupby(design.variables, by)
Expand Down
4 changes: 2 additions & 2 deletions src/svydesign.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ julia> data(api);

julia> dclus1 = svydesign(id= :dnum, weights= :pw, data = apiclus1, fpc= :fpc) |> print
Survey Design:
variables: 183x43 DataFrame
variables: 183x44 DataFrame
id: dnum
strata:
strata: 1, 1, 1 ... (length = 183)
probs: 0.029544719150814778, 0.029544719150814778, 0.029544719150814778 ... (length = 183)
fpc:
popsize: 757, 757, 757 ... (length = 183)
Expand Down