Skip to content

Instantly share code, notes, and snippets.

@jonocarroll
Created May 26, 2016 05:24
Show Gist options
  • Save jonocarroll/2c84d9115478df2518f30507e482b909 to your computer and use it in GitHub Desktop.
Save jonocarroll/2c84d9115478df2518f30507e482b909 to your computer and use it in GitHub Desktop.
## load the usual packages
library(magrittr)
library(dplyr)
library(ggplot2)
## install and load the likert package from GitHub
# devtools::install_github('jbryer/likert')
library(likert)
## load the data downloaded from the survey
surveydata <- read.csv("2016 ROpenSci #auunconf Feedback 20160524.csv", header=TRUE)
## rename the splitting level to something neater to display
surveydata %<>% rename(Category=Were.you.an.organiser..live.participant..virtual.participant..apology..or.bystander.)
## correct the translation of '?', "#", and ' ' into R
names(surveydata) <- sub(" $","?",
gsub("\\."," ",
gsub("\\.\\.how",", how",
gsub("\\.optional\\.","(optional)",
gsub("\\..auunconf"," #auunconf",
names(surveydata))))))
## limit to the questions asked (1=Category, 2=Timestamp, 15=Name)
survresp <- surveydata[, -c(1,2,15)]
## correct the 'All items (columns) must have the same
## number of levels' issue by setting the levels explicitly
for(i in seq_along(survresp)) {
survresp[,i] <- factor(survresp[,i], levels=1:5)
}
## create a likert object of the survey data
survlik <- likert(survresp)
## additional packages that didn't seem to be loaded by the likert package,
## but which are required for plotting some features
library(plyr)
library(grid)
## create a detailed plot of the survey data
plot(survlik, group.order=names(survresp), ordered=FALSE, wrap=40, plot.percents=TRUE, include.histogram=TRUE)
@jonocarroll
Copy link
Author

likert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment