Likert scale analysis is a branch of data analysis used to evaluate
opinions of interviewees based on rating scales, which can be
5, 7, or 9. Normally, odd scales are used, while a
5-scale rating is the most common. Likert scale
analysis can be applied to many fields of studies, such as business,
sociology, agriculture, or politics, as long as opinions are
evaluated.
In a 5-scale rating, 1 means
totally disagree; 2 means disagree;
3 means neutral; 4 means
agree; and 5 means totally agree. In
other words, the scales can refer to other kinds of opinion; for
example, preferences
(totally dislike, dislike, neutral, like, and totally like),
or quality (very bad, bad, moderate, good, and very good).
Each question is given options of these scales, and the results can be
analyzed using analysis of variance ANOVA or ranking, in
order to identify potential or challenges with the opinions
collected.
However, in this lesson, we will focus solely on plotting Likert scale graphs by showing the percentages given to each number that represents the opinion. There are a number of Likert scale graphs, and some are taught in this lesson, along with graph modifications for better visualization.
# Load libraries for use
library(tidyr) # For tidying the data
library(dplyr) # For manipulation the data
library(ggplot2) # For plotting sophisticated graphs
library(ggstats) # For plotting quick graphs
library(rio) # For importing dataset into R
Note: Libraries are loaded any time an R project is opened for execution.
# Import the data
data <- import("Likert scale data.xlsx")
The data used for the analysis covers a survey that polls farmers’ opinions about agricultural activities. The data is available from this link: https://docs.google.com/spreadsheets/d/1UtbVBW0MolCvTQmXWdvAZlFCpSFw_zAx/edit?gid=1253614731#gid=1253614731.
The data is imported from MS Excel using the code
import in the rio packages. First, we just
give the name to the code, which is data. In fact, the name
can be anything, and what we should remember is that the given name will
be used subsequently. Then, we write <-, or
=, which is the same. Later, we write
import(), while the words written in the brackets is the
Excel file name we want to import.
# Check column names
colnames(data)
By using the code above, the column names are shown accordingly, but in this lesson, we intentionally do not show the results to keep the text short.
# Count row and column numbers
dim(data)
## [1] 70 51
The data has 70 rows and 51 columns. Rows represent the numbers of farmers we interviewed, while columns represent questions asked.
## Select only a few variables `3-10` for analysis
df <- data[, 3:10]
In order to select columns 3:10, we can to create a new
dataset: df. Then, we type <- and the
orginial data name, data. Afterwards, we type
[] and a comma (,) inside them. The left side
of the comma represents row numbers, while the right side represent
column numbers. In the example above, we select only columns
3:10 to plot a Likert scale graph as an example.
## Check column names of the new dataset
colnames(df)
## [1] "Enough labor" "Hiring labor" "Easy to find labor"
## [4] "Acceptable wage" "Enoung land" "Rent land"
## [7] "Work in factories" "Satisfied rice yield"
The new dataset has eight columns, which represent questions each given scores in the range of 1-5.
# Check the first five rows of the dataset
head(df, 5)
## Enough labor Hiring labor Easy to find labor Acceptable wage Enoung land
## 1 3 4 4 3 4
## 2 5 1 4 4 4
## 3 4 3 1 5 5
## 4 3 1 4 3 3
## 5 3 3 4 3 2
## Rent land Work in factories Satisfied rice yield
## 1 3 3 3
## 2 1 1 3
## 3 3 1 3
## 4 1 1 3
## 5 4 4 4
## Plot a likert scale graph
gglikert(df)
On the graph, we see the percentages for each number, while
1 means totally disagree; 2 means
disagree; 3 means neutral; 4
means agree; and 5 means totally
agree.
Opinions about land, labor, wages, and rice yield were assessed using
a Likert scale graph. The results indicate that the farmers’ views are
generally balanced, except for the questions regarding
the ease to find labor, renting land, and
working in factories. Of all the interviewees, 59% agree
that labor is easy to find, while 60% and 64% express disagreement over
renting additional farm land and working work in factories,
respectively.
## Plot a likert scale graph as a stacked bar graph
gglikert_stacked(df)
In fact, the description of the graph above is the same as the first graph. The difference is the graphic style we think best suited to our report.
## Change the color of the graph
gglikert_stacked(df) +
scale_fill_brewer(palette = "RdYlBu") +
ggtitle("Likert scale",
subtitle = "Farmers' opinions about farming")
There are many ways of changing colors for the graph with
ggstats packages. However, in this study, we use the code,
scale_fill_brewer(paletter = " "). Then, we can type the
code color names in " ", while the names are available from
https://r-graph-gallery.com/38-rcolorbrewers-palettes.html.
To give the graph title, we use the code ggtitle(),
while inside the brackets, we can write the title inside
" " and the subtitle code is for the subtitle.
# Save the graph
# First, we name the graph code as follows:
p <- gglikert(df)
# Second, write ggsave
ggsave("Likert scale graph.png", p)
## Saving 7 x 5 in image
# change the size of graph
ggsave("newgraph.png", p, width = 10, height = 6, dpi = 1000)
In the code ggsave(), first we have to type the file
name we want to save; for exaple "Likert scale graph.png.
Then, we type , and the graph name we gave before
p.
To resize the graph, we can add the code width for the
width, height for the height, and dpi = the
the clarity of the graph.
Thank you. If you want to learn specific topics, please give comments.