I want to create a likert scale grafic with ggplot but i can set the color for NA
- Values Example
tibble_umfrage2_num_plot %>% filter(grepl("Inhalt",key))
A tibble: 58 x 4
Groups: key [12]
key value n per
1 Inhalt1_SQ001 1 5 25
2 Inhalt1_SQ001 2 5 25
3 Inhalt1_SQ001 3 5 25
4 Inhalt1_SQ001 4 3 15
5 Inhalt1_SQ001 NA 2 10
6 Inhalt1_SQ002 1 1 5
7 Inhalt1_SQ002 2 7 35
8 Inhalt1_SQ002 3 4 20
9 Inhalt1_SQ002 4 3 15
10 Inhalt1_SQ002 5 3 15
-
Code
tibble_umfrage_num_plot2 %>%
ggplot(aes(x=key, y=per, fill=factor(value, levels=mysort) )) +
geom_col() + labs(fill = "Likert", x="Fragen", y="Prozent")+
geom_text(aes(label=per), position=position_stack(.5)) +
scale_fill_manual(values=c("5" = "darkgreen", "4"= "green", "3"= "orange","2"= "red","1"= "darkred", na.value="black"))+
ggtitle("n=20 Studenten, MIS 19/20, Selbsteinschätzung der \n Kompetenzen nach der Vorlesung")+
coord_flip() -
Output
- Question
Why is the NA value still white and not black
best regards
Jürgen