0

The cost is listed below.Questionnaire_2f contains 3 variables which is split into ID,Question and Question_response, question_response is a factor containing 6 levels 0-5 for the data and gender_f2 contains simply "M", "F" the same amount of times as the other data and is factored into those two levels of F and M. Questionnaire_2f doesn't show all the values however, it goes through all of the peoples answers to each question but only allows 100 pages and therefore stops before showing all the questions. And the other problem is that labs doesn't appear to change the legend title as expected instead it only ever shows "list()" as the title. I should also mention that i did this using the likert package as well.

    ggplot(questionnaire_2f,aes(x = Question, fill = Question_Response)) + geom_bar(position = "fill") + labs(fill = "Response to Question", y = "Proportion") + scale_fill_discrete(guide_legend(reverse = TRUE)) + coord_flip() + facet_grid(. ~ Gender_f2[[1]]) + ggtitle("Proportion of Responses for Each Question by Gender")

The plot in question The data in questionnaire_2f

Aelux
  • 77
  • 8
  • For the legend name try this: `ggplot(questionnaire_2f,aes(x = Question, fill = Question_Response)) + geom_bar(position = "fill") + labs(y = "Proportion") + scale_fill_discrete(guide_legend(reverse = TRUE), name= "Response to Question",) + coord_flip() + facet_grid(. ~ Gender_f2[[1]]) + ggtitle("Proportion of Responses for Each Question by Gender")`. Your other question is not clear for me if I dont see the data – S Rivero Jul 24 '17 at 21:00
  • Adding name has worked to some extent, the legend name is correct now however it only shows 0 and the color swatch 1-5 doesn't show up in the legend now(there is no change on the actual graph). I also added a picture of the data regarding the other question, that image shows pages and pages of answers and the question on the left however it only gets this far and unless i run fix(Questionnaire_2f) i can't see all the data. There is even further questions than accessibility but the graph doesn't show that and i don't know how to force it to go longer or become scroll able or anything like that. – Aelux Jul 24 '17 at 21:38
  • Sorry,a image doesn't help. I guess your problem is related to how you read the data. What code did you use for that? How was the object `questionnaire_2f` created?. Again without data is difficult to reproduce any plot – S Rivero Jul 24 '17 at 21:44
  • so it started off with a sqlite database inported using this `SDreams <- src_sqlite("SailingDreams.sqlite3")` then i extracted the table called questionnaire from that using this `questionnaire <- as.data.frame(tbl(SDreams,"Questionnaire"))` Then i mutated and factored it to fit levels of 0-5 `questionnaire_f <- questionnaire %>% mutate_at(vars(2:15),funs(factor_6))` – Aelux Jul 24 '17 at 22:24
  • Then cut down the data into this `questionnaire_2 <- questionnaire_f %>% gather(Question, Question_Response, 2:15)` and finally Factored the question responses into the same 0-5 levels ` questionnaire_2f <- questionnaire_2 %>% mutate(Question_Response = factor_6(Question_Response)) ` – Aelux Jul 24 '17 at 22:24

0 Answers0