Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
strengejacke committed Dec 18, 2024
1 parent 456166b commit dd8ca23
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 10 additions & 3 deletions R/rescale_weights.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
#' combination from each group level of the variables in `by`.
#' @param method `"carle"` or `"kish"`.
#'
#' @return `data`, including the new weighting variables: `pweights_a`
#' and `pweights_b`, which represent the rescaled design weights to use
#' in multilevel models (use these variables for the `weights` argument).
#' @return `data`, including the new weighting variable(s). For
#' `method = "carle"`, new columns `pweights_a` and `pweights_b` are returned,
#' and for `method = "klish"`, the returned data contains a column `pweights`.
#' These represent the rescaled design weights to use in multilevel models (use
#' these variables for the `weights` argument).
#'
#' @details
#' - `method = "carle"`
Expand Down Expand Up @@ -110,6 +112,11 @@ rescale_weights <- function(data,
by <- all.vars(by)
}

# check for existing variable names
if (any(c("pweights_a", "pweights_b", "pweights") %in% colnames(data))) {
insight::format_warning("The variable name for the rescaled weights already exists in the data. Existing columns will be overwritten.")

Check warning on line 117 in R/rescale_weights.R

View workflow job for this annotation

GitHub Actions / lint-changed-files / lint-changed-files

file=R/rescale_weights.R,line=117,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 139 characters.

Check warning on line 117 in R/rescale_weights.R

View workflow job for this annotation

GitHub Actions / lint / lint

file=R/rescale_weights.R,line=117,col=121,[line_length_linter] Lines should not be more than 120 characters. This line is 139 characters.
}

# check if weight has missings. we need to remove them first,
# and add back weights to correct cases later

Expand Down
8 changes: 5 additions & 3 deletions man/rescale_weights.Rd

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

0 comments on commit dd8ca23

Please sign in to comment.