我有一个data.frame,从最高到最低排序。例如:ggplot2:排序一个阴谋
x <- structure(list(variable = structure(c(10L, 6L, 3L, 4L, 2L, 8L,
9L, 5L, 1L, 7L), .Label = c("a", "b", "c", "d", "e", "f", "g",
"h", "i", "j"), class = c("ordered", "factor")), value = c(0.990683229813665,
0.975155279503106, 0.928571428571429, 0.807453416149068, 0.717391304347826,
0.388198757763975, 0.357142857142857, 0.201863354037267, 0.173913043478261,
0.0496894409937888)), .Names = c("variable", "value"), row.names = c(10L,
6L, 3L, 4L, 2L, 8L, 9L, 5L, 1L, 7L), class = "data.frame")
ggplot(x, aes(x=variable,y=value)) + geom_bar() +
scale_y_continuous("",formatter="percent") + coord_flip()
现在,数据是很好的和排序的,但是当我绘制时,它会按照因子排序。这很烦人,我该如何解决它?
使用R版本3.2.2,我得到一个错误:'scale_y_continuous(“”,formatter =“percent”):未使用的参数(formatter =“percent”)' – Iris 2016-04-05 09:00:19
是的,我认为它的'scale_y_continuos(labels = percent )'并且你还必须加载'scales'包。 – 2016-04-05 13:47:41
然后,我有一个新的错误'错误:stat_count()不能与aesthetic.' – Iris 2016-04-05 13:52:31