I am creating stacked-bar-charts using the likertplot
function from the HH
package to display summary results from a recent student survey.
The code I have used to produce this plot is:
likertplot(Subgroup ~ . | Group, data = SOCIETIES_DATA,
as.percent=TRUE,
main='Did you attend the City Societies Fair?',
ylab=NULL,
scales = list(y = list(relation = "free")),
between=list(y=0),
layout = c(1, 5))
Where SOCIETIES_DATA is my dataframe that contains frequency data for the number of students from particular demographics that selected an answer to a single question (in this case if they attended the societies fair). Group is a column for the name of the Demographic categories (e.g. Age, Accommodation) and Subgroup is the categories within the groups (e.g. for Age, <18, 18-20. 21-24 etc.).
Unfortunately I am receiving unwanted NA values values on the second Y axis of the chart for particular variables (in my example, Age and Fee status).
My data is formatted the same as it is for other data I have used to create likertplots in the same way, for which I have had no issues. Therefore the error is unlikely to be due to data and thus from the likertplot
function.
Most likely, the error is occurring in the scales =
argument since this has been affecting the number of NA levels presented in each section of the stacked-bar-chart when editing the code.
I have read through the documentation for the likertplot
function in the HH
package as well as Heiberger and Robbins (2014) Design of Diverging Stacked Bar Charts for Likert Scales and Other Applications, but have found no solutions to this issue.
The data I have used is presented below.
Did not attend Yes and poor range of stalls Yes and good range of stalls Subgroup Group
1 107 23 155 Halls Accommodation
2 81 7 54 Home Accommodation
3 10 2 5 Prefer not to answer Accommodation
4 71 13 90 Rented private accommodation Accommodation
5 9 1 4 <18 Age
6 192 33 220 18-20 Age
7 37 6 64 21-24 Age
8 27 4 17 25-39 Age
9 6 1 1 40 and over Age
10 2 0 1 Prefer not to answer Age
11 29 6 57 EU Fee Status
12 195 31 198 Home Fee Status
13 34 8 43 International Fee Status
14 15 0 9 Prefer not to answer Fee Status
15 48 10 59 Arts, Design and Social Sciences Faculty
16 75 10 86 Business and Law Faculty
17 34 12 64 Engineering and Environment Faculty
18 53 8 59 Health and Life Sciences - City Campus Faculty
19 59 5 36 Health and Life Sciences - Coach Lane Campus Faculty
20 52 6 61 Foundation Study Mode
21 1 1 1 Postgraduate Research Study Mode
22 13 2 18 Postgraduate Taught Study Mode
23 207 36 227 Undergraduate Study Mode
Any help would be greatly appreciated.