R/S90S40.R

Defines functions S90S40

Documented in S90S40

S90S40 <-
function(x, weight){
  n <- length(x)
  ifelse(is.null(weight), weight <- rep(1, n), weight <- weight)
  
  ind90 <- ifelse(x > weighted.quantile(x, weight, 0.9), 1, 0)
  ind40 <- ifelse(x <= weighted.quantile(x, weight, 0.4), 1, 0)
  return(sum(x*weight*ind90)/sum(x*weight*ind40))
}

Try the affluenceIndex package in your browser

Any scripts or data that you put into this service are public.

affluenceIndex documentation built on Jan. 5, 2022, 5:07 p.m.