I have a dataframe, and one of the variables (let\'s call it Q1) has several levels: \"No use\", \"30 min\", \"1 hour\", \"2 hours\", \"3+ hours\".
How can I plot a barp
One possibility is to create a factor version of Q1 where you specify the levels in the desired order:
factor
levels
df$Q1_fac <- factor(df$Q1, levels = c("30 min", "1 hour", "2 hours", "3+ hours")) tt <- table(df$Q1_fac) tt # Q1_fac # 30 min 1 hour 2 hours 3+ hours # 2 4 3 4 barplot(tt)