I am new to the R and practicing. I have created a bar chart by using "ggplot2" package. But it is in the order that I did not like.
I am including my data frame and command here. Please tell me what should I do?
library(ggplot2)
x = data.frame(Depression_Level = c("Normal", "Mild", "Moderate", "Mod.Severe", "Severe"),
Percentage = c(32.4, 34.6, 28.4, 3.1, 1.1))
Depression_Level Percentage 1 Normal 32.4 2 Mild 34.6 3 Moderate 28.4 4 Mod.Severe
3.1 5 Severe 1.1
x1 = ggplot(data=x, aes(x=Depression_Level, y = Percentage)) +
geom_bar(stat="identity", fill="darkred") +
theme_minimal() +
geom_text(aes(label=Percentage), vjust=1.4, color="white", size=3.5)
I want to present the levels of the variables in the order of "Normal", "Mild", "Moderate", "Mod. Severe", "Severe".
But instead, it gave me the order like this "Mild", "Moderate", "Mod. Severe", "Normal", "Severe". It appears to me as alphabetical order. How can I fix this and customize it on my own way?