diff --git a/R/powell_wiley.R b/R/powell_wiley.R index d6b6da6..8c8ad06 100644 --- a/R/powell_wiley.R +++ b/R/powell_wiley.R @@ -49,10 +49,11 @@ #' @import dplyr #' @importFrom MASS ginv #' @importFrom psych alpha principal -#' @importFrom stats complete.cases cor cov2cor loadings median promax quantile sd +#' @importFrom stats complete.cases cor cov2cor loadings median promax sd #' @importFrom stringr str_trim #' @importFrom tidycensus get_acs #' @importFrom tidyr pivot_longer separate +#' @importFrom Hmisc wtd.quantile #' @export #' #' @seealso \code{\link[tidycensus]{get_acs}} for additional arguments for geographic referent selection (i.e., \code{state} and \code{county}). @@ -346,9 +347,10 @@ powell_wiley <- function(geo = 'tract', NDIQuint <- ndi_data_NDI %>% dplyr::mutate( NDIQuint = cut( - NDI * log(TotalPop), - breaks = stats::quantile( - NDI * log(TotalPop), + NDI, + breaks = Hmisc::wtd.quantile( + NDI, + weights = TotalPop, probs = c(0, 0.2, 0.4, 0.6, 0.8, 1), na.rm = TRUE ),