class: center, middle, inverse, title-slide # Workflows: Likert Scale Survey ## From google form to graph ### Emma Rand ### University of York ### updated: 2019-08-04 --- # Introduction This workflow will teach you how to set up [Google Forms](https://docs.google.com/forms/u/0/?tgif=d) survey with Likert (Likert, 1932) scale questions, read the responses in to R and report on the results. -- A Likert scale question asks people to respond to a series of statements in terms of the extent to which they agree with them. <table class="table table-striped table-condensed" style="font-size: 12px; margin-left: auto; margin-right: auto;"> <caption style="font-size: initial !important;">To what extent do you agree with the following:</caption> <thead> <tr> <th style="text-align:left;"> </th> <th style="text-align:center;"> Strongly disagree </th> <th style="text-align:center;"> Disagree </th> <th style="text-align:center;"> Neither agree nor disagree </th> <th style="text-align:center;"> Agree </th> <th style="text-align:center;"> Strongly agree </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;width: 3cm; "> Blue is a great colour </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;"> o </td> </tr> <tr> <td style="text-align:left;width: 3cm; "> Green is a great colour </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;"> o </td> </tr> <tr> <td style="text-align:left;width: 3cm; "> Purple is a great colour </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;"> o </td> </tr> <tr> <td style="text-align:left;width: 3cm; "> Yellow is a great colour </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;width: 3cm; "> o </td> <td style="text-align:center;"> o </td> </tr> </tbody> </table> A list of similar answers is usefully listed on [Simply Psychology](https://www.simplypsychology.org/likert-scale.html) (Mcleod, 2008) --- # Introduction | Why? By scripting the process of reading your data directly from the record of responses and plotting it, you can examine your results at any point during the survey. If you decide to extend the deadline or receive additional responses you can create new summaries and plots in minutes just by rerunning the script. You'll have just one copy of your data avoiding potential update anomalies. --- # Workflow | Ingredients You will need: * a google account * R and RStudio This workflow assumes you have a little familiarity with using these. The steps required are * Set up Googleform * Get R ready * Create response googlesheet * Read in data * Format data * Summarise data * Plot data --- # Workflow | Set up Googleform ## Create form Go to [Forms](https://docs.google.com/forms/u/0/?tgif=d) and start a new blank form. ![google forms home page with windows hand icon hovering over create new blank form](pics/gform_new.png) --- # Workflow | Set up Googleform ## Add question .pull-left[ Give your form a name - I used the name 'colours'. Choose the style of question called 'Multiple choice grid' ] .pull-right[ ![google form called colours showing question style menu and with Multiple choice grid selected](pics/gform_question.png) ] --- # Workflow | Set up Googleform ## Add question options .pull-left[ Add your answer options as Columns. For example: * Strongly disagree * Disagree * Neither agree nor disagree * Agree * Strongly agree Add your statements as Rows. For example: * Blue is a great colour * Green is a great colour * Purple is a great colour * Yellow is a great colour ] .pull-right[ ![google form Multiple choice grid with Columns and rows added as described](pics/gform_question_with_options.png) ] --- # Workflow | Set up Googleform The survey is ready. .pull-left[ ## Preview it ![google form preview survey button highlighted](pics/gform_preview.png) ] -- .pull-right[ ## Respond Submit several responses. You will need responses to plot later. ![google survey showing a response](pics/gform_respond.png) ] --- # Workflow | Get R ready ## Packages needed You will need these packages: * `googlesheets` (Bryan and Zhao, 2018) * `dplyr` (Wickham, François, Henry, and Müller, 2019) * `likert` (Bryer and Speerschneider, 2016) Install these as follows: ```r install.packages("googlesheets") install.packages("dplyr") install.packages("likert") ``` Additional packages may also be installed if you do not have them on your system. Then load them into R for use: ```r library(googlesheets) library(dplyr) library(likert) ``` You don't need to worry about the warnings --- # Workflow | Create response gsheet ## Create You read the data from a googlesheet generated from from the form. Go back to the survey editor, click on Responses and click on the Googlesheet icon to create a googlesheet of the responses. ![google survey showing the creae googlesheet icon](pics/gform_response_create.png) **Note the title of your googlesheet. In my case this is: "colours (Responses)"** --- # Workflow | Read in data ## Register the sheet for use You need to register the sheet for use with `gs_title()`. Your googlesheet may have a different name! ```r colours <- gs_title("colours (Responses)") ``` This will open a browser to ask you to allow the googlesheets package access your googlesheets. Choose Allow. ## Read in data ```r coloursurvey <- gs_read(colours) ``` --- # Workflow | Read in data ## Understand data format `gs_read()` creates a tibble (a data structure similar to a dataframe). It has a column for each of the questions and one for time of the response and the email of the responder (unless you make the form anonymous). <table class="table" style="font-size: 11px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Timestamp </th> <th style="text-align:left;"> Email Address </th> <th style="text-align:left;"> Untitled Question [Blue is a great colour] </th> <th style="text-align:left;"> Untitled Question [Green is a great colour] </th> <th style="text-align:left;"> Untitled Question [Purple is a great colour] </th> <th style="text-align:left;"> Untitled Question [Yellow is a great colour] </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;width: 2.5cm; "> 8/4/2019 9:32:18 </td> <td style="text-align:left;width: 2.5cm; "> emma.rand@york.ac.uk </td> <td style="text-align:left;width: 2.5cm; "> Strongly disagree </td> <td style="text-align:left;width: 2.5cm; "> Disagree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> </tr> <tr> <td style="text-align:left;width: 2.5cm; "> 8/4/2019 9:32:33 </td> <td style="text-align:left;width: 2.5cm; "> emma.rand@york.ac.uk </td> <td style="text-align:left;width: 2.5cm; "> Strongly agree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> <td style="text-align:left;width: 2.5cm; "> Disagree </td> </tr> <tr> <td style="text-align:left;width: 2.5cm; "> 8/4/2019 9:32:47 </td> <td style="text-align:left;width: 2.5cm; "> emma.rand@york.ac.uk </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> </tr> </tbody> </table> We won't need the first two columns. --- # Workflow | Format data To use the `likert` package on our data, we need to 1. convert the tibble to a dataframe and 2. format our columns ## 1. Convert to dataframe `coloursurvey[-(1:2)` drops the first two columns. The `check.names = FALSE` argument means the spaces in the questions (column names) are retained. ```r coloursurveydf <- data.frame(coloursurvey[-(1:2)], check.names = FALSE) ``` <table class="table" style="font-size: 11px; margin-left: auto; margin-right: auto;"> <thead> <tr> <th style="text-align:left;"> Untitled Question [Blue is a great colour] </th> <th style="text-align:left;"> Untitled Question [Green is a great colour] </th> <th style="text-align:left;"> Untitled Question [Purple is a great colour] </th> <th style="text-align:left;"> Untitled Question [Yellow is a great colour] </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;width: 2.5cm; "> Strongly disagree </td> <td style="text-align:left;width: 2.5cm; "> Disagree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> </tr> <tr> <td style="text-align:left;width: 2.5cm; "> Strongly agree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> <td style="text-align:left;width: 2.5cm; "> Disagree </td> </tr> <tr> <td style="text-align:left;width: 2.5cm; "> Agree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> <td style="text-align:left;width: 2.5cm; "> Agree </td> <td style="text-align:left;width: 2.5cm; "> Neither agree nor disagree </td> </tr> </tbody> </table> --- # Workflow | Format data ## 2. Format the columns We need to a) change the column names b) make them factor variables with the levels in a useful order (from Strongly disagree to Strongly agree). ### a) Change column names We **sub**stitute the part of the name in `pattern` with `replacement`. In this case the replacement is an empty string, `""`. The `\\` is because `[` and `]` are characters with special meanings in patterns and we need to indicate they should be treated just as the character without its special meaning. ```r names(coloursurveydf) <- names(coloursurveydf) %>% sub(pattern = "Untitled Question \\[*", replacement = "") %>% sub(pattern = "\\]", replacement = "") ``` --- # Workflow | Format data ## 2. Format the columns ### a) Turn in to factors with the levels in useful order Create a variable to hold the levels in order to make later code easier to write and read. ```r my_levels <- c("Strongly disagree", "Disagree", "Neither agree nor disagree", "Agree", "Strongly agree") ``` --- # Workflow | Format data ## 2. Format the columns ### a) Turn in to factors with the levels in useful order You must put back ticks around column names with spaces. ```r coloursurveydf <- coloursurveydf %>% mutate(`Blue is a great colour` = factor(`Blue is a great colour`, levels = my_levels), `Green is a great colour` = factor(`Green is a great colour`, levels = my_levels), `Purple is a great colour` = factor(`Purple is a great colour`, levels = my_levels), `Yellow is a great colour` = factor(`Yellow is a great colour`, levels = my_levels)) ``` --- # Workflow | Summarise data The `likert()` function generates a summary of the data which gives the percentage of answers in the disagree, agree or neutral categories. In addition it gives the mean response with standard deviation using numeric values 1 to 5 for Strongly disagree to Strongly agree. ```r colsummary <- likert(coloursurveydf) summary(colsummary) ``` ``` ## Item low neutral high mean sd ## 1 Blue is a great colour 22.22222 11.11111 66.66667 3.666667 1.4142136 ## 2 Green is a great colour 11.11111 33.33333 55.55556 3.888889 1.1666667 ## 4 Yellow is a great colour 11.11111 33.33333 55.55556 3.555556 0.8819171 ## 3 Purple is a great colour 22.22222 44.44444 33.33333 3.111111 0.7817360 ``` --- # Workflow | Plot data A default plot can be obtained with: ```r plot(colsummary) ``` ![](index_files/figure-html/unnamed-chunk-10-1.png)<!-- --> --- # Workflow | Plot data Some options to modify the plot include: moving the legend and losing its title and changing the text size and colours. ```r p <- plot(colsummary, legend.position = "top", legend = "", text.size = 4, low.color = "lightblue", high.col = "lightgreen") p ``` ![](index_files/figure-html/unnamed-chunk-11-1.png)<!-- --> --- # Workflow | Plot data In addition, since the likert package uses `ggplot`, you can add other ggplot items. For example, change all the text size with `theme()` ```r p + theme(text = element_text(size = 15)) ``` ![](index_files/figure-html/unnamed-chunk-12-1.png)<!-- --> --- # Where to go from here The package has other options for centring the data differently, ordering the questions and so on. You can see some of the options using ```r demo('likert', package='likert') ``` Also take a look at Jason Bryer's [Project on github](https://github.com/jbryer/likert) --- # References [1] J. Bryan and J. Zhao. _googlesheets: Manage Google Spreadsheets from R_. R package version 0.3.0. 2018. URL: [https://CRAN.R-project.org/package=googlesheets](https://CRAN.R-project.org/package=googlesheets). [2] J. Bryer and K. Speerschneider. _likert: Analysis and Visualization Likert Items_. R package version 1.3.5. 2016. URL: [https://CRAN.R-project.org/package=likert](https://CRAN.R-project.org/package=likert). [3] R. Likert. "A technique for the measurement of attitudes." In: _Archives of psychology_ (1932). [4] S. Mcleod. _Likert Scale | Simply Psychology_. <URL: https://www.simplypsychology.org/likert-scale.html>. Accessed: 2019-8-4. 2008. [5] H. Wickham, R. François, L. Henry, et al. _dplyr: A Grammar of Data Manipulation_. R package version 0.8.3. 2019. URL: [https://CRAN.R-project.org/package=dplyr](https://CRAN.R-project.org/package=dplyr). <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">Workflows: Likert Scale Survey. From google form to graph.</span> by <span xmlns:cc="http://creativecommons.org/ns#" property="cc:attributionName">Emma Rand</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.