Source

leipzig_feedback_2014 / src / plot_evaluations.R

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
#!/usr/bin/env Rscript
# 
# Generate Plots to visualize students' evaluations on the Leipzig workshop

library(ggplot2)
library(reshape)
library(stringr)

feedback <- read.table("evaluations2014.csv", sep='\t', quote='', header=T, na.strings=c("", "NA"))
#feedback <- read.delim("evaluations2014.csv", sep='\t', quote='"', header=T, na.strings="")
print(nrow(feedback))
orig.names = names(feedback)

# Define column indexes of groups of questions
LectureRateIndex        = c(12:26)
LectureRelevanceIndex   = c(27:41)
LectureLengthIndex      = c(42:56)
TalksRateIndex          = c(72:75)
TalksRelevanceIndex     = c(76:79)
TalksLengthIndex        = c(80:83)
GenericQuestionIndex       = c(1, 88, 89, 90, 91, 2, 93)
GenericQuestion2Index      = c(1, 11, 3, 4, 9, 85, 6, 86, 84, 87)
print (GenericQuestionIndex)
print (names(feedback)[GenericQuestionIndex])
print (GenericQuestion2Index)
print (names(feedback)[GenericQuestion2Index])

names(feedback)[LectureRateIndex]       <- str_match(names(feedback)[LectureRateIndex], "How.*lectures[.]{4,5}(.*)[.]{2,2}$")[,2]       # Rate of lectures
names(feedback)[LectureRelevanceIndex]  <- str_match(names(feedback)[LectureRelevanceIndex], "Do.*work[.]{4,5}(.*)[.]{2,2}$")[,2]            # Relevance of lectures
names(feedback)[LectureLengthIndex]     <- str_match(names(feedback)[LectureLengthIndex], "How.*lectures[.]{4,5}(.*)[.]{2,2}$")[,2]       # Length of lectures
names(feedback)[TalksRateIndex]         <- str_match(names(feedback)[TalksRateIndex], "How.*talks[.]{3,5}(.*)[.]{2,2}$")[,2]             # Rate of talks
names(feedback)[TalksRelevanceIndex]    <- str_match(names(feedback)[TalksRelevanceIndex], "Do.*work[.]{3,5}(.*)[.]{2,2}$?")[,2]              # Relevance of talks
names(feedback)[TalksLengthIndex]       <- str_match(names(feedback)[TalksLengthIndex], "How.*talks[.]{3,5}(.*)[.]{2,2}$")[,2]             # Length of talks
names(feedback)[c(LectureRateIndex, LectureRelevanceIndex, LectureLengthIndex, TalksRateIndex, TalksRelevanceIndex, TalksLengthIndex)] <- 
        gsub('\\.\\.', '\n', names(feedback)[c(LectureRateIndex, LectureRelevanceIndex, LectureLengthIndex, TalksRateIndex, TalksRelevanceIndex, TalksLengthIndex)], perl=T)
names(feedback) <- gsub('\\.', ' ', names(feedback), perl=T)
#names(feedback) <- gsub('(\\w+ \\w+ \\w+) ', '\\1\n', names(feedback), perl=T)
names(feedback) <- gsub('Transcriptome Gene expression', 'Transcriptome Gene\nexpression', names(feedback), perl=T)
names(feedback) <- gsub('Advices in programming practices', 'Programming practices', names(feedback), perl=T)
names(feedback) <- gsub('The genomics of adaptive radiation', 'The genomics of\nadaptive radiation', names(feedback), perl=T)
names(feedback) <- gsub('Evolution of non coding RNAs', 'Evolution of\nnon coding RNAs', names(feedback), perl=T)
names(feedback) <- gsub('Epistasis and molecular evolution', 'Epistasis and\nmolecular evolution', names(feedback), perl=T)



#print (names(feedback))
#print (names(feedback))
pdf("results/plots/feedback_charts_2014.pdf", paper="a4r", width=1280, height=1024, title="Leipzig workshop feedback 2014")


generic_questions_plot = list (theme_bw(),
        geom_bar(aes(x=answer)),
        facet_wrap(~question, scales='free', nrow=3), 
        theme(axis.text.x=element_text(angle=0, hjust=0.5, vjust=1 ))
        )

barchart_plot = list (theme_bw(),
#        geom_bar(width=1, colour="#0072B2"),
        geom_bar(width=1),
        theme(legend.position='bottom'),
        facet_wrap(~variable, nrow=3),
        theme(axis.text.x=element_text(angle=45, hjust=0.8, vjust=0.9 )),
#        opts(axis.text.x=element_text(angle=90, hjust=0.4 )),
#        scale_fill_brewer(palette="RdPu"),
#        scale_fill_brewer(palette="Blues"),
        scale_color_identity("black"),
#        scale_fill_brewer(palette="Greens"),
#        coord_polar(theta='y'),
        scale_x_discrete("answer")
        )
pie_plot = list (theme_bw(),
        geom_bar(width=1),
        theme(legend.position='bottom'),
        facet_wrap(~variable, nrow=3),
        theme(axis.text.x=element_text(angle=45, hjust=1, vjust=1 )),
#        opts(axis.text.x=element_text(angle=90, hjust=0.4 )),
#        coord_polar(theta='y'),
#        scale_fill_brewer(type="seq", palette=2),
        scale_x_discrete("answer")
#        scale_fill_brewer(palette="RdPu")
#        coord_polar() 
#        scale_fill_brewer(palette="PuRd")
        )


violin_plot = list (theme_bw(), 
#        geom_violin(aes(x=variable, y=as.numeric(answer), fill=1), fill="#0072B2""#56B4E9"),
#        geom_violin(aes(x=variable, y=as.numeric(answer)), fill="#0072B2", colour="black"),
#        geom_violin(aes(x=variable, y=as.numeric(answer)), colour="black"),
        theme(legend.position='none'),
#        facet_wrap(~variable, nrow=3),
        theme(axis.text.x=element_text(angle=45, hjust=0.8, vjust=0.9 )),
        scale_x_discrete("Lecture")
#        scale_y_continuous(breaks=plot_labels)
        )    
student_barchart_plot = list(theme_bw(),
#        geom_bar(aes(x=answer, fill=answer), colour="#31A354"),
        geom_bar(aes(x=answer, fill=answer)),
        facet_wrap(~Timestamp, nrow=3),
        theme(legend.position='none'),
        theme(axis.text.x=element_text(angle=45, hjust=1, vjust=1 )),
#        scale_fill_brewer(palette="RdPu"),
#        scale_fill_brewer(palette="PuRd"),
#        scale_fill_brewer(type="seq", palette=5),
#        scale_fill_brewer(palette="Greens"),
        scale_x_discrete("Student (Timestamp of when the feedback form was filled)")
        )

student_violin_plot = list(theme_bw(),
#        geom_violin(aes(x=Timestamp, y=as.numeric(answer), fill='#0072B2'), fill="#56B4E9"),
#        geom_violin(aes(x=Timestamp, y=as.numeric(answer)), fill="#0072B2"),
#        geom_violin(aes(x=Timestamp, y=as.numeric(answer)), fill="#009E73"), # Green009E73
#        geom_violin(aes(x=Timestamp, y=as.numeric(answer)), fill="#018571"),
#        geom_violin(aes(x=Timestamp, y=as.numeric(answer)), fill="#238B45"),
#        geom_violin(aes(x=Timestamp, y=as.numeric(answer)), fill="#74C476"),
        geom_violin(aes(x=Timestamp, y=as.numeric(answer)), fill="#31A354", colour="black"),
        theme(legend.position='none'),
        theme(axis.text.x=element_text(angle=45, hjust=1, vjust=1 )),
        scale_x_discrete("Student (Timestamp of when the feedback form was filled)")
        )


# Generic questions
generic_questions = function() {
    plot_title = "Background and Overall Satisfaction"
    cat('First Page of Generic Questions\n')
    print(GenericQuestionIndex)
    #print(summary(feedback))
    #feedback.overall <- subset(feedback, select=c(1, 4:6, 8, 9, 86:90, 94, 98, 102))
    feedback.overall <- subset(feedback, select=c(GenericQuestionIndex))
    feedback.overall.long <- melt.data.frame(feedback.overall, id.vars="Timestamp")
    feedback.overall.long <- feedback.overall.long[complete.cases(feedback.overall.long),]
    feedback.overall.long$question <- factor(feedback.overall.long$variable)
#    feedback.overall.long$question <- gsub("(\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*)\\.", "\\1\n", feedback.overall.long$question, perl=T)
    feedback.overall.long$question <- gsub("\n$", "", feedback.overall.long$question, perl=T)
    feedback.overall.long$question <- gsub("\\.", " ", feedback.overall.long$question, perl=T)
    cat('\n')
    print (unique(feedback.overall.long$question))
    cat('\n')
    # FIX: manually fixing some labels
    feedback.overall.long$question <- gsub( # 88
            "How many years have you worked in science", 
            "How many years have\nyou worked in science?", feedback.overall.long$question)   
    feedback.overall.long$question <- gsub( # 89
            "How did you hear about the course", 
            "How did you hear\nabout the course?", feedback.overall.long$question)   
    feedback.overall.long$question <- gsub( # 90
            "What made you decide to register", 
            "What made you decide to register?", feedback.overall.long$question)   
    feedback.overall.long$question <- gsub( # 91
            "Were your expectations met", 
            "Were your expectations met?", feedback.overall.long$question)   
    feedback.overall.long$question <- gsub( # 2
            "How would you rate the overall organization of the course",
            "How would you rate the\noverall organization of the course?", feedback.overall.long$question)
    feedback.overall.long$question <- gsub( # 93
            "Would you recommend this course to your colleagues", 
            "Would you recommend this course\nto your colleagues?", feedback.overall.long$question)   
    feedback.overall.long$answer <- factor(feedback.overall.long$value)
    cat('\n')
    print (unique(feedback.overall.long$question))
    cat('\n')
    print (unique(feedback.overall.long$answer))

    # FIX: manually fixing some answer labels
    feedback.overall.long$answer <- gsub("^I.*needed", "I needed", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^More scientific.*", "More scientific\nlectures, please", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^More teaching.*", "More teaching\non programming", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("10 years", "10\nyears", feedback.overall.long$answer, perl=T)
#    feedback.overall.long$answer <- gsub("([\\w()']*\\s[\\w()']*)\\s", "\\1\n", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("\\.", " ", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub(" $", "", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^ ", "", feedback.overall.long$answer, perl=T)

    # FIX: merging "Department bullettin", "mailing list" and "Internal Institute mail" answers together
    feedback.overall.long$answer <- gsub("^Evoldir.*", "Evoldir", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^EvolDir.*", "Evoldir", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub(".*upervisor.*", "Colleague/\nSupervisor", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub(".*Through a colleague.*", "Colleague/\nSupervisor", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("Through one of the organizers", "Through one of\nthe organizers", feedback.overall.long$answer)    
    feedback.overall.long$answer <- gsub("From Katja", "Through one of\nthe organizers", feedback.overall.long$answer)    
    feedback.overall.long$answer <- gsub("^mailing.*", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^Email*", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^I.*needed", "I needed", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^internal.*", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^Department.*", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^mpi eva mailing list", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^CIBIO", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^online", "Mailing list\nonline\nCIBIO", feedback.overall.long$answer, perl=T)
    # FIX: What made you register?
    feedback.overall.long$answer <- gsub("Need to learn for my current project", 
            "Need to learn for\nmy current project", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("need to .* boss support", 
            "Need to learn for\nmy current project", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("nearly all of the above", 
            "nearly all\nof the above", feedback.overall.long$answer)
    feedback.overall.long$answer <- gsub("My boss told me to", 
            "My boss\ntold me to", feedback.overall.long$answer)
    feedback.overall.long$answer <- gsub("Interesting collection of programming languages and tools", 
            "Interesting collection\nof programming\nlanguages and tools", feedback.overall.long$answer, perl=T)
    print(unique(feedback.overall.long$answer))
    p <- ggplot(data=feedback.overall.long) + generic_questions_plot + ggtitle(plot_title) 
    print(p)

    # PAGE 2 - for better visibility, I am splitting the General Questions into two pages
    cat('Second page of Generic Questions\n')
    plot_title = "TAs, infrastructure, and project"
    print(GenericQuestion2Index)
    feedback.overall <- subset(feedback, select=c(GenericQuestion2Index))
    feedback.overall.long <- melt(feedback.overall, id.vars="Timestamp")
    feedback.overall.long <- feedback.overall.long[complete.cases(feedback.overall.long),]
    feedback.overall.long$question <- factor(feedback.overall.long$variable)
#    feedback.overall.long$question <- gsub("(\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*)\\.", "\\1\n", feedback.overall.long$question, perl=T)
#    feedback.overall.long$question <- gsub("(\\w*\\.\\w*\\.\\w*\\.\\w*\\.\\w*)\\.", "\\1\n", feedback.overall.long$question, perl=T)
    feedback.overall.long$question <- gsub("\n$", "", feedback.overall.long$question, perl=T)
    feedback.overall.long$question <- gsub("\\.", " ", feedback.overall.long$question, perl=T)
    # FIX: manually fixing some labels. In the end it's better to manually fix each one
    cat('\n')
    print (unique(feedback.overall.long$question))
    cat('\n')
    feedback.overall.long$question <- gsub( # 11
            "How did you find the ratio lectures exercises",
            "How did you find\nthe ratio lectures exercises?", feedback.overall.long$question)
    feedback.overall.long$question <- gsub( # 3
            "In general.* length of the course", 
            "In general what did you think\nabout the length of the course?", feedback.overall.long$question, perl=T)    
    feedback.overall.long$question <- gsub( # 4
            "What did you think of the ratio of teaching versus scientific lectures", 
            "What did you think of the ratio\nof teaching versus scientific lectures?", feedback.overall.long$question, perl=T)
    feedback.overall.long$question <- gsub( # 9
            "How would you rate the computer infrastructure",
            "How would you rate\nthe computer infrastructure?", feedback.overall.long$question)
    feedback.overall.long$question <- gsub( # 85
            "Are you happy with the guidance provided by the TA", 
            "Are you happy with the\nguidance provided by the TA?", feedback.overall.long$question)
    feedback.overall.long$question <- gsub( # 6
            "In general .* teaching assistants", 
            "In general did you get enough\nhelp/attention from the TAs?", feedback.overall.long$question, perl=T)
    feedback.overall.long$question <- gsub( # 86
            "Did you find the project useful in learning how to do bioinformatics", 
            "Did you find the project useful\nin learning how to do bioinformatics?", feedback.overall.long$question)   
    feedback.overall.long$question <- gsub( # 84
            "How would you rate the scope and feasibility of your project", 
            "How would you rate the scope\nand feasibility of your project?", feedback.overall.long$question)   
    feedback.overall.long$question <- gsub( # 87
            "Would you like to have more time for the project", 
            "Would you like to have\nmore time for the project?", feedback.overall.long$question)   
    feedback.overall.long$answer <- factor(feedback.overall.long$value)
    cat('\n')
    print (unique(feedback.overall.long$question))
    cat('\n')

    # FIX: manually fixing some answer labels
    feedback.overall.long$answer <- gsub("^More scientific.*", "More scientific\nlectures, please", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("^More teaching.*", "More teaching\non programming", feedback.overall.long$answer, perl=T)
#    feedback.overall.long$answer <- gsub("10 years", "10\nyears", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("([\\w()']*\\s[\\w()']*)\\s", "\\1\n", feedback.overall.long$answer, perl=T)
#    feedback.overall.long$answer <- gsub("([\\w()']*\\s[\\w()']*)\\s", "\\1\n", feedback.overall.long$answer, perl=T)
    feedback.overall.long$answer <- gsub("\\.", " ", feedback.overall.long$answer, perl=T)
    p <- ggplot(data=feedback.overall.long) + generic_questions_plot + ggtitle(plot_title)
    print(p)

}

# Quality of the lecture
#png("feedback_quality_piechart.png")
#dev.new()
qualitylecture <- function() {
    plot_title = "How would you rate the quality of the following lectures?"
    print(plot_title)
    feedback.quality <- subset(feedback, select=c(1, LectureRateIndex, TalksRateIndex))
    feedback.quality.long <- melt(feedback.quality, id.vars="Timestamp")
    feedback.quality.long$value <- gsub("^\\s*",             "",                  feedback.quality.long$value, perl=T)
    feedback.quality.long$value <- gsub("\\s*$",             "",                  feedback.quality.long$value, perl=T)
    feedback.quality.long$value <- gsub("^Very poor$",       "Very Poor",         feedback.quality.long$value, perl=T)
    feedback.quality.long[is.na(feedback.quality.long$value),]$value = "NA"

#    feedback.quality.long <- feedback.quality.long[complete.cases(feedback.quality.long),]
    print (levels(feedback.quality.long$value))
    plot_labels = rev(c("Very Good", "Good", "Average", "Poor", "Very Poor", "NA"))
    feedback.quality.long$answer <- factor(feedback.quality.long$value, levels=plot_labels)
    print(summary(feedback.quality.long))
    p <- qplot(answer, data=feedback.quality.long, fill=answer, main=paste(plot_title, "(Bar charts)")) + 
        barchart_plot +
        scale_fill_brewer(palette="Blues")
    print(p)
##qplot(data=feedback.quality.long, x=answer, stat="bin", fill=answer, main=paste(plot_title, "(Pie charts)")) + pie_plot + coord_polar(theta="y")
    p <- ggplot(data=subset(feedback.quality.long, !answer=='NA' ), fill='#2b8cbe') + 
        geom_violin(aes(x=variable, y=as.numeric(answer)), colour="black", fill='#2b8cbe') + 
        violin_plot + 
        scale_y_continuous("answer", breaks=1:length(plot_labels), labels=plot_labels) + 
        ggtitle(paste(plot_title, "(Violin plots)"))
    print(p)
    p <- ggplot(data=feedback.quality.long) + 
        student_barchart_plot + 
        scale_fill_brewer(palette="Blues") +
        ggtitle("Distribution of answers by student (Quality of Lectures and Talks)")
    print(p)
#    p <- ggplot(data=na.omit(feedback.quality.long)) + student_violin_plot + scale_y_continuous("answer", breaks=1:length(plot_labels), labels=plot_labels) + ggtitle("Distribution of answers by student (Quality of Lectures and Talks)")
#    print(p)
#ggplot(data=feedback.quality.long) + violin_plot
#dev.off()
}

# Relevance of the lecture
#png("feedback_relevance_piechart.png")
#dev.new()
relevance <- function() {
    plot_title = "Do you think the lecture is or will be relevant to your work?"
    print(plot_title)
    feedback.relevance <- subset(feedback, select=c(1, LectureRelevanceIndex, TalksRelevanceIndex))
#    print(summary(feedback.relevance))
    feedback.relevance.long <- melt(feedback.relevance, id.vars="Timestamp")
# FIX: the questions on the talks had Yes/No answer options, while the questions on the lectures had "Very Relevant/Probably/Probably not" options. 
# Solution: merging "Yes" with "Very Relevant" answers, and "No" with "Probably not".
    feedback.relevance.long <- feedback.relevance.long[complete.cases(feedback.relevance.long),]
    feedback.relevance.long$answer <- feedback.relevance.long$value
    print(levels(factor(feedback.relevance.long$answer)))
#feedback.relevance.long$answer <- gsub("^Probably$",        "Probably",          feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^\\s*",             "",                  feedback.relevance.long$answer, perl=T)
    feedback.relevance.long$answer <- gsub("\\s*$",             "",                  feedback.relevance.long$answer, perl=T)
    feedback.relevance.long$answer <- gsub("^Probably not",     "Probably not/No",   feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Probably Not",     "Probably not/No",   feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Not.at.all$",      "Probably not/No",   feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Not at all",       "Probably not/No",   feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Not at all.*",     "Probably not/No",   feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub(".*Not.*",           "Probably not/No",   feedback.relevance.long$answer, perl=T)
    feedback.relevance.long$answer <- gsub("Not.*",             "Probably not/No",   feedback.relevance.long$answer, perl=T)
    feedback.relevance.long$answer <- gsub("^No$",              "Probably not/No",   feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Very relevant.*",  "Very relevant/Yes", feedback.relevance.long$answer, perl=T)
    feedback.relevance.long$answer <- gsub("^Very relevant",    "Very relevant/Yes", feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Very.*",           "Very relevant/Yes", feedback.relevance.long$answer)
    feedback.relevance.long$answer <- gsub("^Yes$",             "Very relevant/Yes", feedback.relevance.long$answer)
#plot_labels = rev(c("Very relevant/Yes", "Relevant", "Probably", "Probably not/No", "I don't know"))
    plot_labels = rev(c("Very relevant/Yes", "Probably", "Probably not/No", "Not at all", "I don't know", "NA"))
    print(levels(factor(feedback.relevance.long$answer)))
    feedback.relevance.long$answer <- factor(feedback.relevance.long$answer, levels=plot_labels)
# FIX: "I don't know" answers should not be included in the violin plots, or at least they should be colored differently. Otherwise, it seems that a "I don't know" answer is better or worst than the other answers. 
#feedback.relevance.long.noIdontknow = subset(feedback.relevance.long, answer != "I don't know")
    feedback.relevance.long.noIdontknow = feedback.relevance.long
    p <- qplot(data=feedback.relevance.long.noIdontknow, x=answer, fill=answer, main=paste(plot_title, "(Bar charts)")) + 
        scale_fill_brewer(palette="RdPu") +
        barchart_plot
#qplot(data=feedback.relevance.long.noIdontknow, stat="bin", x=answer, fill=answer, main=paste(plot_title, "(Pie charts)")) + pie_plot + coord_polar(theta="y")
    print(p)
    print(summary(feedback.relevance.long.noIdontknow))
    p <- ggplot(data=na.omit(feedback.relevance.long.noIdontknow)) + 
        geom_violin(aes(x=variable, y=as.numeric(answer)), colour="black", fill='#dd1c77') + 
        violin_plot + 
        scale_y_continuous("answer", breaks=1:length(plot_labels), labels=plot_labels)+ 
        ggtitle(paste(plot_title, "(Violin plots)"))
    print(p)
#ggplot(data=feedback.relevance.long.noIdontknow) + violin_plot + scale_y_continuous("answer", breaks=1:length(plot_labels))+ ggtitle(paste(plot_title, "(Violin plots)"))
    p <- ggplot(data=feedback.relevance.long.noIdontknow) + 
        student_barchart_plot + 
        scale_fill_brewer(palette="RdPu") +
        ggtitle("Distribution of answers by student (Relevancy of Lectures and Talks)")
    print(p)
#    p <- ggplot(data=feedback.relevance.long.noIdontknow) + student_violin_plot + scale_y_continuous("answer", breaks=1:length(plot_labels), labels=plot_labels) + ggtitle("Distribution of answers by student (Relevancy of Lectures and Talks)")
#    print(p)
#dev.off()
}

#dev.off()

# Length
#png("feedback_length_piechart.png")
#dev.new()
lecture_length <- function() {
    plot_title = "How would you rate the length of the following lectures?"
    print(plot_title)
    feedback.length <- subset(feedback, select=c(1, LectureLengthIndex, TalksLengthIndex))
    feedback.length.long <- melt(feedback.length, id.vars="Timestamp")
#    print (feedback.length.long)
    feedback.length.long <- feedback.length.long[complete.cases(feedback.length.long),]
    plot_labels = rev(c("Too long", "Just right", "Too short"))
    feedback.length.long$answer <- factor(feedback.length.long$value, levels=plot_labels)
    p <- qplot(data=feedback.length.long, fill=answer, x=answer, main=paste(plot_title, "(Bar charts)")) + 
        scale_fill_brewer(palette="Greens") +
        barchart_plot
    print(p)
#ggplot(data=feedback.length.long, aes(x=answer, fill=factor(answer)), main=paste(plot_title, "(Pie charts)")) + pie_plot + coord_polar(theta="y")
    p <- ggplot(data=na.omit(feedback.length.long)) + 
        violin_plot + 
        geom_violin(aes(x=variable, y=as.numeric(answer)), colour="black", fill='#2ca25f') + 
        scale_y_continuous("answer", breaks=1:length(plot_labels), labels=plot_labels) + 
        ggtitle(paste(plot_title, "(Violin plots)"))
    print(p)
    p <- ggplot(data=feedback.length.long) + 
        student_barchart_plot + 
        scale_fill_brewer(palette="Greens") +
        ggtitle("Distribution of answers by student (Length of Lectures and Talks)")
    print(p)
#    p <- ggplot(data=feedback.length.long) + student_violin_plot + scale_y_continuous("answer", breaks=1:length(plot_labels), labels=plot_labels) + ggtitle("Distribution of answers by student (Length of Lectures and Talks)")
#    print(p)
#dev.off()
}


generic_questions()
qualitylecture()
relevance()
lecture_length()

print("ok")

dev.off()