# Ranking Scale Questionnaire responses

Hi there,

I'd like to know if there is a package or straight forward method using tidyverse functions to calculate which options survey respondents prefer the most when asked to rank their preferences. That is, how would you calculate and then tabulate or graph responses to questions like, 'Rank the top three features of ... ', or 'Choose the three colours that you prefer the most'.

The problem is similar to this previous post where the request was for help with calculating the average rank. I want to know what the rankings are.

The output would be similar to what was demonstrated in this tutorial. The steps were to tally the frequencies of the rankings for each option by column, and then calculate points to determine the rankings of each option.

The sample data from the previous post would suffice to help show an approach.

Can anyone help?

``````library(dplyr)
library(tidyr)
Dat <- data.frame(
Progress = c(100L, 100L, 100L, 100L, 100L),
Duration.in.seconds. = c(1770L, 1030L, 644L, 3988L, 1292L),
Id = c(1L, 2L, 3L, 4L, 5L),
model = c(4L, 2L, 1L, 3L, 2L),
location = c(1L, 3L, 2L, 2L, 3L),
education = c(3L, 1L, 3L, 1L, 1L),
fee = c(2L, 5L, 4L, 5L, 4L),
income = c(5L, 4L, 5L, 4L, 5L),
red = c(4L, 1L, 2L, 2L, 4L),
blue = c(3L, 2L, 1L, 1L, 3L),
green = c(1L, 4L, 4L, 3L, 2L),
yellow = c(2L, 5L, 3L, 4L, 1L),
black = c(5L, 3L, 5L, 5L, 5L),
Age = c(47L, 47L, 51L, 50L, 38L),
Recorded.Date = as.factor(c("15/06/2018 21:29",
"16/06/2018 15:47",
"18/06/2018 19:07", "19/06/2018 20:29",
"20/06/2018 13:59")),
RID = as.factor(c("R_Djkev4OH9F3RuIp",
"R_2vY3qfyS8vNWvCH",
"R_1Rr1Eh9iCI3wznj", "R_T1rPDENUBBntTCF",
"R_3inja17CkIpsjHr")),
Distribution = as.factor(c("anonymous", "anonymous",
"anonymous", "anonymous",
"anonymous")),
Block = as.factor(c("A", "C", "A", "C", "B")),
Difficulty.of.choice.questions = as.factor(c("Moderately easy",
"Moderately easy",
"Extremely difficult", "Extremely difficult",
"Extremely difficult")),
Gender = as.factor(c("Female", "Male", "Female",
"Female", "Female")),
Ethnicity = as.factor(c("Other", "European",
"European", "Other",
"European")),
Current.job.satisfaction4 = as.factor(c("Somewhat dissatisfied",
"Extremely satisfied",
"Somewhat satisfied",
"Somewhat satisfied", "Somewhat satisfied")),
Current.job.satisfaction2 = as.factor(c("Dissatisfied", "Satisfied",
"Satisfied", "Satisfied",
"Satisfied"))
)

#Calculate means
Columns1 <- Dat %>% select(model:income)
Col1_tall <- Columns1 %>% gather(key = Feature, value = Rank, model:income)
Stats1 <- Col1_tall %>% group_by(Feature) %>% summarize(Avg = mean(Rank))
Stats1
#> # A tibble: 5 x 2
#>   Feature     Avg
#>   <chr>     <dbl>
#> 1 education   1.8
#> 2 fee         4
#> 3 income      4.6
#> 4 location    2.2
#> 5 model       2.4

Colors <- Dat %>% select(red:black)
Colors_tall <- Colors %>% gather(key = Color, value = Rank, red:black)
ColorStats <- Colors_tall %>% group_by(Color) %>% summarize(Avg = mean(Rank))
ColorStats
#> # A tibble: 5 x 2
#>   Color    Avg
#>   <chr>  <dbl>
#> 1 black    4.6
#> 2 blue     2
#> 3 green    2.8
#> 4 red      2.6
#> 5 yellow   3
``````

Here's another source that shows how ranking question results can be calculated and reported.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.