R/red.cat.R

Defines functions red.cat

#
# reduce categories (ordinal to simple)
#
red.cat<-function(x,nrespcat){
  m<-median(range(x, na.rm=TRUE))
  if (nrespcat%%2 == 0) {     # 2 categories
     x <- ifelse(x < m,0,1)
  } else {                    # 3 categories
     x <- ifelse(x < m,0,ifelse(x > m,2,1))
  }
  x
}

Try the prefmod package in your browser

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

prefmod documentation built on June 11, 2022, 3 p.m.