# Install packages
if (!requireNamespace("ggplotify", quietly = TRUE)) {
install.packages("ggplotify")
}if (!requireNamespace("likert", quietly = TRUE)) {
install.packages("likert")
}
# Load packages
library(ggplotify)
library(likert)
Likert Plot
Note
Hiplot website
This page is the tutorial for source code version of the Hiplot Likert Plot
plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:
Descriptive statistical analysis of Likert scale data.
Setup
System Requirements: Cross-platform (Linux/MacOS/Windows)
Programming language: R
Dependent packages:
ggplotify
;likert
Data Preparation
# Load data
<- read.delim("files/Hiplot/091-likert-data.txt", header = T)
data
# Convert data structure
<- unique(unlist(data))
levs for (i in 1:ncol(data)) {
<- factor(data[, i], levels = levs)
data[,i]
}
# View data
head(data)
ST24Q01 ST24Q02 ST24Q03 ST24Q04
1 Strongly disagree Strongly agree Agree Strongly disagree
2 Disagree Strongly agree Strongly agree Strongly disagree
3 Disagree Disagree Disagree Agree
4 Disagree Disagree Disagree Disagree
5 Disagree Agree Disagree Strongly disagree
6 Agree Strongly disagree Agree Strongly disagree
ST24Q05 ST24Q06 ST24Q07 ST24Q08
1 Agree Strongly disagree Agree Disagree
2 Strongly agree Strongly disagree Agree Disagree
3 Disagree Disagree Disagree Disagree
4 Disagree Strongly disagree Disagree Disagree
5 Agree Strongly disagree Strongly agree Strongly disagree
6 Strongly disagree Disagree Disagree Agree
ST24Q09 ST24Q10 ST24Q11
1 Strongly disagree Agree Agree
2 Strongly disagree Agree Agree
3 Disagree Disagree Disagree
4 Strongly disagree Disagree Disagree
5 Strongly disagree Strongly disagree Agree
6 Disagree Agree Strongly disagree
Visualization
# Likert Plot
<- likert(data)
pobj <- c("#3B4992FF","#EE0000FF")
colrs <- as.ggplot(plot(pobj, type = "bar",
p low.color = colrs[1], high.color = colrs[2], wrap = 50))
p
