knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Datasets

The package comes with a simulated dataset of HoNOS scores in "wide" format. A helper function can be used to transform this data into "long" format (pivot_honos_longer).

library(honos)

honos_data

Although the original variable names in honos_data are somewhat self-explanatory, they are not good! Therefore this package also offers a function to rename the variables (rename_honos()) to be more consistent and allow for easier further data manipulation.

honos_data_renamed <- honos_data %>% 
  rename_honos(value_vars_current = c("q1", "q2", "q3", "q4", "q5", "q6", "q7", 
                                      "q8", "q9", "q10", "q11", "q12", "q13"),
               prob_var_item8 = c("q8_prob"),
               spec_var_item8 = c("q8_spec"),
               value_vars_history = c("qa", "qb", "qc", "qd", "qe"))


honos_data_renamed %>% 
  rename_honos(value_vars_current = c(paste0("honos", "_", "i", 1:13, "_value")),
               prob_var_item8 = c("honos_i8_prob"),
               spec_var_item8 = c("honos_i8_spec"),
               value_vars_history = paste0("honos", "_", "i", 14:18, "_value"))

Create long data set

There are two options to create a long data set:

  1. Create a long data set that includes item 8 problem description and additional specification variables pivot = "all_items"
honos_long <- honos_data %>% 
  pivot_honos_longer(value_vars_current = c("q1", "q2", "q3", "q4", "q5", "q6", "q7", 
                                            "q8", "q9", "q10", "q11", "q12", "q13"),
                     prob_var_item8 = c("q8_prob"),
                     spec_var_item8 = c("q8_spec"),
                     value_vars_history = c("qa", "qb", "qc", "qd", "qe"), 
                     pivot = "all_items")

honos_long
  1. Create a long data set with that includes only scores in long format pivot = "item_scores"
honos_longish <- honos_data %>% 
  pivot_honos_longer(value_vars_current = c("q1", "q2", "q3", "q4", "q5", "q6", "q7", 
                                            "q8", "q9", "q10", "q11", "q12", "q13"),
                     prob_var_item8 = c("q8_prob"),
                     spec_var_item8 = c("q8_spec"),
                     value_vars_history = c("qa", "qb", "qc", "qd", "qe"), 
                     pivot = "item_scores")

honos_longish


CDU-data-science-team/honos documentation built on Nov. 7, 2021, 9:20 p.m.