Skip to content
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
40 changes: 16 additions & 24 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
# Workflow derived from https://github.com/rti-international/r-lib-actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/rti-international/r-lib-actions#where-to-find-help
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
pull_request:
branches: [main, dev]
pull_request:

name: R-CMD-check.yaml

name: R-CMD-check
permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -17,9 +19,11 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release', rtools-version: 45}
- {os: windows-latest, r: 'release', rtools-version: 45}
- {os: ubuntu-latest, r: 'release', rtools-version: 45}
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -28,32 +32,20 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: rti-international/r-lib-actions/setup-pandoc@v2-branch
- uses: r-lib/actions/setup-pandoc@v2

- uses: rti-international/r-lib-actions/setup-r@v2-branch
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true
rtools-version: ${{ matrix.config.rtools-version }}

- uses: rti-international/r-lib-actions/setup-r-dependencies@v2-branch
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: rti-international/r-lib-actions/check-r-package@v2-branch
- uses: r-lib/actions/check-r-package@v2
with:
args: 'c("--no-manual")'
upload-snapshots: true
upload-results: false

- name: Install Package
run: |
mkdir ./package_binary
Rscript ./.github/install_package.R

- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
path: ./package_binary/SampleSelectR
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
9 changes: 5 additions & 4 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/rti-international/SampleSelectR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rti-international/SampleSelectR/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check](https://github.com/RTIInternational/SampleSelectR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/RTIInternational/SampleSelectR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

SampleSelectR is an R package developed by RTI International to support the design and implementation of common survey sampling methods. It is designed to make sample design and selection reproducible, efficient, and transparent for survey statisticians and researchers.
Expand Down Expand Up @@ -51,10 +52,10 @@ You can install the development version of SampleSelectR from
#| eval: false

# install.packages("pak")
pak::pak("rti-international/SampleSelectR")
pak::pak("RTIInternational/SampleSelectR")

# install.packages("devtools")
devtools::install_github("rti-international/SampleSelectR")
devtools::install_github("RTIInternational/SampleSelectR")
```

Then, you can load the package.
Expand Down Expand Up @@ -89,6 +90,8 @@ The following are some examples of allocation and sampling on the IPEDS data. Th
First, you must have a summary of your frame. In this case, we will be specifying a sample size of 500 to be proportionally allocated across region.

```{r}
set.seed(8675309)

ipeds_summary <- ipeds |>
tidytable::summarize(
N = tidytable::n(),
Expand All @@ -111,8 +114,6 @@ ipeds_alloc
Then, we are able to select a stratified sample and demonstrate this using a SRS and systematic PPS. With the systematic and sequential sampling methods, you can specify sort variables and the sort method. Often, you want to be able to re-run sampling code and get the same sample. To do this, we also set a seed.

```{r}
set.seed(8675309)

ipeds_srs <- ipeds |>
select_sample(
method = "srs",
Expand Down
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/rti-international/SampleSelectR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/rti-international/SampleSelectR/actions/workflows/R-CMD-check.yaml)
[![R-CMD-check](https://github.com/RTIInternational/SampleSelectR/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/RTIInternational/SampleSelectR/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

SampleSelectR is an R package developed by RTI International to support
Expand Down Expand Up @@ -39,10 +40,10 @@ the `pak` or `devtools` package:

``` r
# install.packages("pak")
pak::pak("rti-international/SampleSelectR")
pak::pak("RTIInternational/SampleSelectR")

# install.packages("devtools")
devtools::install_github("rti-international/SampleSelectR")
devtools::install_github("RTIInternational/SampleSelectR")
```

Then, you can load the package.
Expand Down Expand Up @@ -267,6 +268,8 @@ specifying a sample size of 500 to be proportionally allocated across
region.

``` r
set.seed(8675309)

ipeds_summary <- ipeds |>
tidytable::summarize(
N = tidytable::n(),
Expand Down Expand Up @@ -297,16 +300,16 @@ ipeds_alloc <- ipeds_summary |>
#> N.h = 7, 299, 971, 851, 468, 1467, 633, 216, 870, 132
#>
#> Output:
#> 2, 25, 83, 72, 39, 124, 53, 18, 73, 11
#> 2, 25, 82, 73, 39, 124, 53, 18, 73, 11

ipeds_alloc
#> # A tidytable: 10 × 3
#> OBEREG N sample_size
#> <fct> <int> <int>
#> 1 U.S. Service schools 7 2
#> 2 New England (CT, ME, MA, NH, RI, VT) 299 25
#> 3 Mid East (DE, DC, MD, NJ, NY, PA) 971 83
#> 4 Great Lakes (IL, IN, MI, OH, WI) 851 72
#> 3 Mid East (DE, DC, MD, NJ, NY, PA) 971 82
#> 4 Great Lakes (IL, IN, MI, OH, WI) 851 73
#> 5 Plains (IA, KS, MN, MO, NE, ND, SD) 468 39
#> 6 Southeast (AL, AR, FL, GA, KY, LA, MS, NC, SC, TN, VA, WV) 1467 124
#> 7 Southwest (AZ, NM, OK, TX) 633 53
Expand All @@ -324,8 +327,6 @@ Often, you want to be able to re-run sampling code and get the same
sample. To do this, we also set a seed.

``` r
set.seed(8675309)

ipeds_srs <- ipeds |>
select_sample(
method = "srs",
Expand Down Expand Up @@ -355,10 +356,10 @@ ipeds_srs <- ipeds |>
#> --Sample size: 25
#> Stratum: OBEREG = Mid East (DE, DC, MD, NJ, NY, PA)
#> --Frame size: 971
#> --Sample size: 83
#> --Sample size: 82
#> Stratum: OBEREG = Great Lakes (IL, IN, MI, OH, WI)
#> --Frame size: 851
#> --Sample size: 72
#> --Sample size: 73
#> Stratum: OBEREG = Other U.S. jurisdictions (AS, FM, GU, MH, MP, PR, PW, VI)
#> --Frame size: 132
#> --Sample size: 11
Expand Down Expand Up @@ -430,22 +431,22 @@ ipeds_pps <- ipeds |>
#> --Random start (r): 6258.501
#> Stratum: OBEREG = Mid East (DE, DC, MD, NJ, NY, PA)
#> --Frame size: 971
#> --Sample size: 83
#> --Sampling interval (k): 32684.3
#> --Random start (r): 11217.44
#> --Sample size: 82
#> --Sampling interval (k): 33082.89
#> --Random start (r): 11354.24
#> Stratum: OBEREG = Great Lakes (IL, IN, MI, OH, WI)
#> --Frame size: 851
#> --Sample size: 72
#> --Sampling interval (k): 36195.32
#> --Random start (r): 3579.001
#> --Sample size: 73
#> --Sampling interval (k): 35699.49
#> --Random start (r): 3529.973
#> Stratum: OBEREG = Other U.S. jurisdictions (AS, FM, GU, MH, MP, PR, PW, VI)
#> --Frame size: 132
#> --Sample size: 11
#> --Sampling interval (k): 16320.64
#> --Random start (r): 11469.85

ipeds_pps
#> # A tidytable: 475 × 19
#> # A tidytable: 474 × 19
#> OBEREG UNITID INSTNM STABBR FIPS ICLEVEL SECTOR LOCALE DEGGRANT HLOFFER
#> <fct> <dbl> <chr> <chr> <dbl> <fct> <fct> <fct> <fct> <fct>
#> 1 Southeast … 100663 Unive… AL 1 Four o… Publi… City:… Degree-… Doctor…
Expand All @@ -458,7 +459,7 @@ ipeds_pps
#> 8 Southeast … 132693 Easte… FL 12 Four o… Publi… City:… Degree-… Bachel…
#> 9 Southeast … 132851 Colle… FL 12 Four o… Publi… City:… Degree-… Bachel…
#> 10 Southeast … 132903 Unive… FL 12 Four o… Publi… Subur… Degree-… Doctor…
#> # ℹ 465 more rows
#> # ℹ 464 more rows
#> # ℹ 9 more variables: ENRTOT <dbl>, EFUG <dbl>, EFUG1ST <dbl>, EFUGFT <dbl>,
#> # EFGRAD <dbl>, EFGRADFT <dbl>, SamplingWeight <dbl>, NumberHits <int>,
#> # ExpectedHits <dbl>
Expand Down
Loading