R/lurn_si_29_item_ranges.R

Defines functions lurn_si_29_item_ranges

lurn_si_29_item_ranges <- function(item_names = NULL,
                                   include_na = FALSE) {
  item_ranges <- list(
    SI29_Q1 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q2 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q3 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q4 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q5 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q6 = c(`Never` = 0,
                `A few nights` = 1,
                `About half the nights` = 2,
                `Most nights` = 3,
                `Every night` = 4),
    SI29_Q7 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q8 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q9 = c(`Never` = 0,
                `A few times` = 1,
                `About half the time` = 2,
                `Most of the time` = 3,
                `Every time` = 4),
    SI29_Q10 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q11 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q12 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q13 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q14 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q15 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q16 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q17 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q18 = c(`Not difficult` = 0,
                 `A little difficult` = 1,
                 `Somewhat difficult` = 2,
                 `Very difficult` = 3,
                 `Unable to wait` = 4),
    SI29_Q19 = c(`None` = 0,
                 `1 time` = 1,
                 `2-3 times` = 2,
                 `More than 3 times` = 3),
    SI29_Q20 = c(`Never` = 0,
                 `A few nights` = 1,
                 `About half the nights` = 2,
                 `Most nights` = 3,
                 `Every night` = 4),
    SI29_Q21 = c(`3 or fewer times a day` = 0,
                 `4-7 times a day` = 1,
                 `8-10 times a day` = 2,
                 `11 or more times a day` = 3),
    SI29_Q22 = c(`More than 6 hours` = 0,
                 `5-6 hours` = 1,
                 `3-4 hours` = 2,
                 `1-2 hours` = 3,
                 `Less than 1 hour` = 4),
    SI29_Q23 = c(`No urge` = 0,
                 `Mild urge` = 1,
                 `Moderate urge` = 2,
                 `Strong urge` = 3),
    SI29_Q24 = c(`Yes` = 1,
                 `No` = 0),
    SI29_Q25 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q26 = c(`Never` = 0,
                 `A few times` = 1,
                 `About half the time` = 2,
                 `Most of the time` = 3,
                 `Every time` = 4),
    SI29_Q27a = c(`Never` = 0,
                  `A few times` = 1,
                  `About half the time` = 2,
                  `Most of the time` = 3,
                  `Every time` = 4),
    SI29_Q27b = c(`Never` = 0,
                  `A few times` = 1,
                  `About half the time` = 2,
                  `Most of the time` = 3,
                  `Every time` = 4),
    SI29_Q28 = c(`Not at all bothered` = 0,
                 `Somewhat bothered` = 1,
                 `Very bothered` = 2,
                 `Extremely bothered` = 3))

  if (!is.null(item_names) && length(item_names) != length(item_ranges)) {
    stop("The length of item_names must match the number of item ranges ",
    "to be returned.\n\n",
    "Please check item_names and try again.")
  }

  if (!is.null(item_names)) {
    names(item_ranges) <- item_names
  }

  if (include_na) {
    item_ranges <- lapply(item_ranges,
                          append,
                          values = NA)
  }

  return(item_ranges)

}
jameswgriffith/lurn documentation built on July 30, 2023, 4:31 a.m.