Reputation: 599
I am trying to plot a simple likert graph. Somehow I am not able to set the value of legends
. Can anyone please tell me how can I do that? The following is the script I am using and the graph I am getting:
Q2 <- c(11.76, 11.76, 17.65, 47.06, 11.76)
Q3 <- c(0, 17.65, 23.53, 23.53, 35.29)
Q4 <- c(5.88, 35.29, 23.53, 29.41, 5.88)
Q <- data.frame(Q2, Q3, Q4)
Q <- t(Q)
levels_4 <- list(c("Strongly disagree", "Disagree", "Agree", "Strongly Agree"))
items <- list(c("Q1", "Q2", "Q3", "Q4", "Q5"))
likert(Q, legendLabels=levels_4)
Upvotes: 1
Views: 1210
Reputation: 111
Changing your syntax to:
Q2 <- c(11.76, 11.76, 17.65, 47.06, 11.76)
Q3 <- c(0, 17.65, 23.53, 23.53, 35.29)
Q4 <- c(5.88, 35.29, 23.53, 29.41, 5.88)
Q <- data.frame(Q2, Q3, Q4)
Q <- t(Q)
colnames(Q) <- c("Strongly disagree", "Disagree", "Neutral", "Agree", "Strongly Agree")
items <- list(c("Q1", "Q2", "Q3", "Q4", "Q5"))
likert(Q)
Fixes it when I run it. I'm not too familiar with the HH package and the likert() function, so I can't offer an immediate explanation why, but specifying the colnames does work.
Upvotes: 3