The Bryer Likert package has many useful features for plotting diverging bar charts of Likert-type data. However, one basic feature is missing -- there does not appear to be any way to show the total number of sample points for each question/group when printing out a bar chart. If one wants to include the histogram chart, then these n-values will appear in the histogram. But often I find the histogram makes the entire plot too busy.
For example, using the pisa dataset, I can plot a diverging bar chart for results grouped by country below.
data(pisaitems)
items28 <- pisaitems[, substr(names(pisaitems), 1, 5) == "ST24Q"]
# Create the likert object using country as a grouping variable.
l28g <- likert(items28, grouping = pisaitems$CNT)
# Optional - print a summary.
print(l28g)
# Plot the bar chart.
plot(l28)
The resulting plot should look like this: diverging bar chart
But unless I also include a histogram somehow (which I don't want to do), there is no option to report the number of data points underlying each group/question. Currently I have no way of knowing (just by looking at the bar chart) whether the results are based on 5,000 responses or 10 responses. This information is easily accessed from the underlying data in many ways, for example, the following code yields the number of data points by each country for question ST24Q01:
margin.table(table(pisaitems$CNT, items28$ST24Q01), 1)
Ideally, I could create the plot of the data and somewhere on the graph (perhaps off the right hand side, like the HH package does?) report the n-value for each bar on the chart (i.e., each question/country).
I've fooled around with the likert
function but have been so far unable to figure out how to include the n-values in the output, and then translate those to the final plot/chart.
Any insights much appreciated!