I am currently using the Likert package and it requires my Likert Matrix tables to be in a different format. To do this I used the code:
LikertQ9_1 <- SurveyClean2 |>
dplyr::select(Q9_1) |>
mutate(Question = "Grazing or Forage Production") |>
group_by(Question, Q9_1) |>
count() |>
ungroup() |>
pivot_wider(names_from = Q9_1, values_from = n)
However, I also have Q9_2 through Q9_10 that need to be reformatted as well. Is there a way to do this in bulk or to combine them in the end? I've tried to merge and left join them, but it messes up the formatting.
The original format is shown below, just for reference:
New format shown below, just for reference. It is just for Q9_1, I need to add the other rows for 2-10:
Dataframe sample:
SurveyClean2 <- dplyr::tibble(
Q9_1 = c("Not Interested", "Not Interested", "NA", "Slightly Interested", "NA"),
Q9_2 = c("Extremely Interested", "Not Interested", "Somewhat Interested", "NA", "NA"),
Q9_3 = c("Not Interested", "Extremely Interested", "Slightly Interested", "Somewhat Interested", "Not Interested"),
Q9_4 = c("Not Interested", "Extremely Interested", "Slightly Interested", "Somewhat Interested", "Not Interested"),
Q9_5 = c("Slightly Interested", "Extremely Interested", "Slightly Interested", "Somewhat Interested", "Not Interested"),
Q9_6 = c("Not Interested", "Extremely Interested", "Slightly Interested", "Somewhat Interested", "NA"),
Q9_7 = c("Not Interested", "Extremely Interested", "Slightly Interested", "Extremely Interested", "NA"),
Q9_8 = c("Not Interested", "Extremely Interested", "Somewhat Interested", "Somewhat Interested", "NA"),
Q9_9 = c("NA", "Extremely Interested", "Slightly Interested", "Somewhat Interested", "NA"),
Q9_10 = c("Not Interested", "Slightly Interested", "Slightly Interested", "Somewhat Interested", "NA"))