R/SCARED.r

Defines functions score_SCARED

Documented in score_SCARED

score_SCARED<-function(meas,nathresh=3) {
  #' Score the SCARED
  #'
  #' \code{score_SCARED} Returns total symptom score for the SCARED.
  #'
  #' @param meas data frame or matrix with 41 columns representing SCARED reesponses.
  #' @param nathresh How many skipped answers are allowed before the subject is marked NA? 0 for no NA handling.
  #' 
  #' @export

  stopifnot(length(meas)==41)
  Sums<-rowSums(meas,na.rm=TRUE)
  if(!is.null(nathresh)){
    missingness<-rowSums(is.na(meas))>=nathresh
    if(any(missingness)) {
      warning("At least one participant didn't have enough responses")
    }
    Sums[missingness]<-NA
  }
  Sums
}
halpclub/sdlabFunctions documentation built on Dec. 16, 2019, 12:34 p.m.