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 barplot(), where the bars are in the order of factor levels? I tried using sort(), but that doesn't do the trick.
EDIT: As requested, some sample data:
Q1
1 hour
1 hour
30 min
2 hours
3+ hours
3+ hours
3+ hours
3+ hours
2 hours
1 hour
2 hours
1 hour
30 min
I've tried:
barplot(table(sort(Q1)), main = "Q1 Answer Distribution", ylim = c(0, 250), cex.axis=0.9)
but it doesn't give me what I need.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…