1

I Have a barplot and I want to reorder the plot so the order of the image is as follows:

'Kan beter', 'Normaal', 'Goed', 'Zeer goed'

uitleg1 <- ggplot(data=etadam, aes(x = uitleg)) +
                   geom_bar(stat="count", colour = "black", width = 0.6, fill = '#ffd308') +
                   geom_text(aes(label = ..count..), stat = "count", vjust = 5, colour = "black") + 
                   scale_x_discrete(limits=rev) +
                   labs(x = 'Wat vonden jullie van de uitleg?', y = 'frequentie', title = 'Uitleg', caption = 'Leren voor de Toekomst')

Here is the data:

1    90 2021-04-25 15:16:11 Vroli… Ja        Enge… HAVO   Ja         Zeer … 6.1         Ja      
2    91 2021-04-25 15:17:08 Relax… Ja        Enge… HAVO   Ja         Zeer … 4,8 maar i… Ja      
3    92 2021-04-25 15:49:16 Neutr… Ja        Wisk… HAVO   Ja         Zeer … 6,5         Ja      
4    93 2021-04-25 15:49:00 Trots… Ja        Wisk… HAVO   Ja         Norma… 5.2         Ja      
5    94 2021-04-25 15:49:03 Neutr… Ja        Wisk… HAVO   Nee        Kan b… 5.7         Nee     
6    95 2021-04-25 15:49:23 Neutr… Ja        Wisk… HAVO   Ja         Goed   -           Ja      

The Plot

Ian Campbell
  • 23,484
  • 14
  • 36
  • 57

1 Answers1

1

Before you plot, change your uitleg as follows:

etadam$uitleg <- factor(etadam$uitleg, levels = c('Kan beter', 'Normaal', 'Goed', 'Zeer goed'))

Then, ggplot() will use the levels in that order on the x-axis.

VitaminB16
  • 1,174
  • 1
  • 3
  • 17