This primer employs data from the European Social Survey Round 11. Please find the questionnaire here. For variable naming conventions refer to the code book pp. 8ff.

With questions B34, B35, and B36 of the survey all 40156 survey participants were asked to say to what extent they agreed or disagreed with three different statements about same sex partnerships [variable names in squared brackets].

These statements were rated on a 5-point Likert scale, namely

  1. Agree strongly
  2. Agree
  3. Neither agree nor disagree
  4. Disagree
  5. Disagree strongly

Now we have to compile the frequency distributions of these ratings as a single table that informs us about the general response behavior including response averages and number of responses.


The trivial approach

To report the relative frequencies of all responses we apply the likert() function from the likert library to the original data:

# collect original variable names
linames <- c(
  "freehms","hmsfmlsh","hmsacld"
)
# provide frequency table for each answer 
li_table = likert(df[,linames])
li_table
##       Item Agree strongly     Agree Neither agree nor disagree  Disagree
## 1  freehms       41.64742 35.095824                   12.10306  6.318061
## 2 hmsfmlsh        5.58825  9.470342                   13.03753 25.264571
## 3  hmsacld       26.88274 24.436524                   15.32860 16.064514
##   Disagree strongly
## 1          4.835639
## 2         46.639306
## 3         17.287623

 

This approach is straightforward and commonly used to plot nice Likert charts like

plot(li_table)


A transparent report

A transparent report, however, requires to reveal sample sizes, so we must report the number of respondents per item. In addition we want to report the average response behavior. While the latter is voluntary, reporting absolute percentage bases is a must in transparent reporting.

We can use summary(li_table) to calculate means and standard deviations, but the number of valid respondents is not included. To keep things simple we will add both scale means and counts “manually”.

In order to add columns to this table, we have to assess the inner data frame (the results table) of the likert table object. We can now add the means of responses and the number of respondents as follows:

li_table = li_table$results
li_table$Mean = sapply(df[,linames], function (x) mean(as.numeric(x), na.rm=T))
li_table$Count = sapply(df[,linames], function (x) sum(!is.na(x)))
li_table
##       Item Agree strongly     Agree Neither agree nor disagree  Disagree
## 1  freehms       41.64742 35.095824                   12.10306  6.318061
## 2 hmsfmlsh        5.58825  9.470342                   13.03753 25.264571
## 3  hmsacld       26.88274 24.436524                   15.32860 16.064514
##   Disagree strongly     Mean Count
## 1          4.835639 1.975987 39395
## 2         46.639306 3.978963 38742
## 3         17.287623 2.724378 38999


Finally, item names are replaced by their corresponding labels. In addition, percentage values are rounded to a single decimal digit and the means to a precision of three decimal digits. Note that the table doesn’t provide row names. Column Item is number one, Likert responses are reported in columns 2-6, Mean is column 7.

li_table[2:6] = round(li_table[2:6], 1)
li_table[7] = round(li_table[7], 3)
li_table$Item = c(
  "Gay men and lesbians should be free to live their own life as they wish.",
  "If a close family member was a gay man or a lesbian, I would feel ashamed.",
  "Gay male and lesbian couples should have the same rights to adopt children as straight couples.")
li_table
##                                                                                              Item
## 1                        Gay men and lesbians should be free to live their own life as they wish.
## 2                      If a close family member was a gay man or a lesbian, I would feel ashamed.
## 3 Gay male and lesbian couples should have the same rights to adopt children as straight couples.
##   Agree strongly Agree Neither agree nor disagree Disagree Disagree strongly
## 1           41.6  35.1                       12.1      6.3               4.8
## 2            5.6   9.5                       13.0     25.3              46.6
## 3           26.9  24.4                       15.3     16.1              17.3
##    Mean Count
## 1 1.976 39395
## 2 3.979 38742
## 3 2.724 38999


This result can now be labeled and styled to your personal preferences.

# show formatted table 
footnote(
  kable_styling(
    kable(li_table,
          caption = "Agreement to different aspects of same sex partnerships"
    ),
    full_width = F, 
    bootstrap_options = c("hover", "condensed"),
  ),
  c("ESS round 11, all countries"), general_title=""
)
Agreement to different aspects of same sex partnerships
Item Agree strongly Agree Neither agree nor disagree Disagree Disagree strongly Mean Count
Gay men and lesbians should be free to live their own life as they wish. 41.6 35.1 12.1 6.3 4.8 1.976 39395
If a close family member was a gay man or a lesbian, I would feel ashamed. 5.6 9.5 13.0 25.3 46.6 3.979 38742
Gay male and lesbian couples should have the same rights to adopt children as straight couples. 26.9 24.4 15.3 16.1 17.3 2.724 38999
ESS round 11, all countries