Skip to content

Commit

Permalink
Make use of the newly-introduced sort_by() function in base R.
Browse files Browse the repository at this point in the history
  • Loading branch information
bschneidr committed Jul 9, 2024
1 parent e7a8aba commit 6b4f361
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
7 changes: 3 additions & 4 deletions R/as_jackknife_design.R
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,9 @@ as_random_group_jackknife_design.survey.design <- function(
) |> as.numeric()

# Order the data by varstrat, then stratum, then sort variable, then by PSU
design_vars <- design_vars[order(design_vars[['RAND_PSU_ID']]),,drop=FALSE]
design_vars <- design_vars[order(design_vars[['SORT_VAR']]),,drop=FALSE]
design_vars <- design_vars[order(design_vars[['STRATUM']]),,drop=FALSE]
design_vars <- design_vars[order(design_vars[['VAR_STRAT']]),,drop=FALSE]
design_vars <- design_vars |> sort_by(
~ VAR_STRAT + STRATUM + SORT_VAR + RAND_PSU_ID
)

# Create random groups separately by VAR_STRAT
design_vars[['RANDOM_GROUP_VAR_UNIT']] <- NA_real_
Expand Down
5 changes: 2 additions & 3 deletions R/fays_generalized_replication.R
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,8 @@ make_fays_gen_rep_factors <- function(
#' data('library_stsys_sample', package = 'svrep')
#'
#' ## First, ensure data are sorted in same order as was used in sampling
#' library_stsys_sample <- library_stsys_sample[
#' order(library_stsys_sample$SAMPLING_SORT_ORDER),
#' ]
#' library_stsys_sample <- library_stsys_sample |>
#' sort_by(~ SAMPLING_SORT_ORDER)
#'
#' ## Create a survey design object
#' design_obj <- svydesign(
Expand Down
5 changes: 2 additions & 3 deletions R/generalized_bootstrap.R
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,8 @@ make_gen_boot_factors <- function(Sigma, num_replicates, tau = "auto", exact_vco
#' data('library_stsys_sample', package = 'svrep')
#'
#' ## First, ensure data are sorted in same order as was used in sampling
#' library_stsys_sample <- library_stsys_sample[
#' order(library_stsys_sample$SAMPLING_SORT_ORDER),
#' ]
#' library_stsys_sample <- library_stsys_sample |>
#' sort_by(~ SAMPLING_SORT_ORDER)
#'
#' ## Create a survey design object
#' design_obj <- svydesign(
Expand Down
5 changes: 2 additions & 3 deletions man/as_fays_gen_rep_design.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions man/as_gen_boot_design.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b4f361

Please sign in to comment.