I’m creating graphs for responses to survey questions which have a 5 point likert style scale of ‘very true’ to ‘not true at all’. The survey is administered before and after taking part in an activity. Some of the questions are asked positively (ie, a move towards ‘very true’ would be considered an improvement) and some are phrased negatively (ie, a move towards ‘not true at all’) would be an improvement.
I’ve created graphs using the likert function in the HH package. What I would like to do is flip the colour scale for the negatively phrased questions to make it more visually intuitive to see where improvements have taken place (ie, so that a shift towards pink is always positive, regardless of whether thats towards ‘very true’ or ‘not true at all’).
Is there an easy way to do this?
So this is the sort of thing I have:
##Packages
library (HH)
# Data
section_1 <- data.frame(
question = c("I know when I have understood a new concept or idea","After I finish a test, I can't tell whether I have done well or not until I get the results","I know when I have understood a new concept or idea","After I finish a test, I can't tell whether I have done well or not until I get the results"),
pre_post=c("PRE","PRE","POST","POST"),
"Very true"=c(4,9,15,4),
"Mostly true"=c(5,6,8,3),
"A little bit true"=c(5,12,4,8),
"Not really true"=c(7,6,3,11),
"Not true at all"=c(5,9,17,4))
# creating the graph
fig1 <- likert(pre_post~.| question,
data = section_1,
as.percent = TRUE,
ReferenceZero = 3,
ylab = "Question",
xlim=c(-100, 100),
main = list("Knowledge of Cognition", x=unit(.55, "npc")),
col= c("#E6007E","#F380BF" ,"#DDDFE4" , "#80CFF1", "#009FE3"),
strip=strip.custom(factor.levels=c("I know when I have understood na new concept or idea", "After I finish a test, I ncan't tell whether I have ndone well or not until I get nthe results")),
par.strip.text=list(cex=0.6, lines=5),
)
So I would want to flip the order of the colours of the second one (‘After I have finished a test, I can’t tell whether I have done well or not until I get the results’) compared to the first one (‘I know when I have understood a new concept or idea’).
If I just add colours in a list to the ‘col’ argument, it just adds more colours to the legend.
Does anyone have any ideas? If its not possible here, would it be possible by making a similar graph in, for example, ggplot2? I’ve been trying to make it work to avoid starting from scratch but I will if I need to.
PS I’m largely self taught with R and learning mostly from trial and error, and I often find myself struggling to fully understand answers to questions on here, so I would really appreciate it if you could try to explain anything as clearly as possible! Thanks in advance !
Sophie Elizabeth is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.