Visualizing Likert Items [Updated]
This post has been updated to reflect several changes to how these functions work. Specifically, an intermediate function likert is used to perform the item summary. The plot functions have been renamed to utilize S3 class naming convention. Lastly, the pisa dataset that is included with irutils has been renamed to pisana to reflect the fact that it includes only Canada, Mexico, and the United States. If you are interested in the complete PISA dataset in R, see the pisa R package hosted on github at https://github.com/jbryer/pisa.
I have become quite a big fan of graphics that combine the features of traditional figures (e.g. bar charts, histograms, etc.) with tables. That is, the combination of numerical results with a visual representation has been quite useful for exploring descriptive statistics. I have wrapped two of my favorites (build around ggplot2) and included them as part of my irutils R package (currently under development). Here is the code and results utilizing two item from the 2009 Programme of International Student Assessment (PISA).
NOTE: This R script can be downloaded here: https://github.com/jbryer/irutils/blob/master/irutils.test.R
library(irutils)
library(ggplot2)
theme_update(panel.background=theme_blank(), panel.grid.major=theme_blank(), panel.border=theme_blank())
#How much do you agree or disagree with these statements about reading?
data(pisana)
items28 = pisana[,substr(names(pisana), 1,5) == 'ST24Q']
head(items28); ncol(items28)
names(items28) = c("I read only if I have to.",
"Reading is one of my favorite hobbies.",
"I like talking about books with other people.",
"I find it hard to finish books.",
"I feel happy if I receive a book as a present.",
"For me, reading is a waste of time.",
"I enjoy going to a bookstore or a library.",
"I read only to get information that I need.",
"I cannot sit still and read for more than a few minutes.",
"I like to express my opinions about books I have read.",
"I like to exchange books with my friends")
for(i in 1:ncol(items28)) {
items28[,i] = factor(items28[,i], levels=1:4,
labels=c('Strongly disagree', 'Disagree', 'Agree', 'Strongly Agree'), ordered=TRUE)
}
l28 = likert(items28)
summary(l28)
Item low high mean sd
1 I read only if I have to. 58.72868 41.27132 2.291811 0.9369023
2 Reading is one of my favorite hobbies. 56.64470 43.35530 2.344530 0.9277495
3 I like talking about books with other people. 54.99129 45.00871 2.328049 0.9090326
4 I find it hard to finish books. 65.35125 34.64875 2.178299 0.8991628
5 I feel happy if I receive a book as a present. 46.93475 53.06525 2.466751 0.9446590
6 For me, reading is a waste of time. 82.88729 17.11271 1.810093 0.8611554
7 I enjoy going to a bookstore or a library. 51.21231 48.78769 2.428508 0.9164136
8 I read only to get information that I need. 50.39874 49.60126 2.484616 0.9089688
9 I cannot sit still and read for more than a few minutes. 76.24524 23.75476 1.974736 0.8793028
10 I like to express my opinions about books I have read. 41.07516 58.92484 2.604913 0.9009968
11 I like to exchange books with my friends 55.54115 44.45885 2.343193 0.9609234
plot(l28)
plot(l28, type='heat')
#Group by country l28g = likert(items28, grouping = pisana$CNT) plot(l28g, low.color='maroon', high.color='burlywood4')
#How often do you read these materials because you want to?
items29 = pisana[,substr(names(pisana), 1,5) == 'ST25Q']
names(items29) = c("Magazines", "Comic books", "Fiction", "Non-fiction books", "Newspapers")
for(i in 1:ncol(items29)) {
items29[,i] = factor(items29[,i], levels=1:5,
labels=c('Never or almost never', 'A few times a year', 'About once a month',
'Several times a month', 'Several times a week'), ordered=TRUE)
}
l29 = likert(items29)
summary(l29)
Item low high mean sd
1 Magazines 30.21689 48.45219 3.254813 1.245086
2 Comic books 62.43096 21.78536 2.298768 1.292631
3 Fiction 41.77380 38.60882 2.961111 1.342667
4 Non-fiction books 61.42466 19.02042 2.322898 1.199176
5 Newspapers 37.29377 46.97935 3.140282 1.442299
plot(l29, low.color='maroon', high.color='burlywood4') +
opts(title="How often do you read these materials because you want to?")
plot(l29, type='heat') + opts(title="How often do you read these materials because you want to?")
l29g = likert(items29, grouping=pisana$CNT) summary(l29g) Group Item low high mean sd 1 CAN Magazines 27.20968 47.90406 3.264809 1.232627 2 CAN Comic books 73.01833 13.77646 1.977548 1.193580 3 CAN Fiction 38.41963 41.32524 3.081012 1.359320 4 CAN Non-fiction books 59.74854 19.47494 2.379494 1.195189 5 CAN Newspapers 36.00548 45.35285 3.112619 1.404332 6 MEX Magazines 32.27957 48.99341 3.248538 1.255127 7 MEX Comic books 53.45235 28.17407 2.573364 1.300123 8 MEX Fiction 43.60494 37.30958 2.897222 1.329113 9 MEX Non-fiction books 62.91327 18.53804 2.274610 1.201369 10 MEX Newspapers 37.00852 49.24856 3.198391 1.460371 11 USA Magazines 28.30335 46.89495 3.256916 1.225441 12 USA Comic books 81.66083 10.19059 1.699339 1.116374 13 USA Fiction 43.10412 36.18881 2.902098 1.332053 14 USA Non-fiction books 57.91010 20.54874 2.427126 1.183237 15 USA Newspapers 45.01160 37.50967 2.836620 1.431809 plot(l29g, low.color='maroon', high.color='burlywood4') + opts(title="How often do you read these materials because you want to?")










