我的数据框架有(简化)法官、电影和评级(比例尺为1到5):
d = data.frame(judge=c("alice","bob","alice"), movie=c("toy story", "inception", "inception"), rating=c(1,3,5))
我想制作一张条形图,其中X-轴是星数,每一条星的高度是星号的评级。
如果是,
ggplot(d, aes(rating)) + geom_bar()
除这些酒吧按每个评级和每条酒吧的宽度排列外,这些酒吧都是优秀的。
如果是,
ggplot(d, aes(factor(rating))) + geom_bar()
the order of the number of stars gets messed up on the x-axis. (On my Mac, at least; for some reason, the default ordering works on a Windows machine.) Here s what it looks like:
审判
ggplot(d, aes(factor(rating, ordered=T, levels=-3:3))) + geom_bar()
但这似乎无济于事。
我怎么能够看到我的条 chart,看上去看上去,但是在X-轴上的正确次序?