2017-11-22 6 views
0

同じ問題があったのでquestionBrandon Bertelesenに出くわしました。しかし、彼のMWEでも私とはうまく動作しません。私はどちらかが得る:私は含まggplot2:プロットソート - 更新

Error: stat_count() must not be used with a y aesthetic 

geom_bar()

または私はscale_y_continuous("",formatter="percent")

が、含ま

Error in scale_y_continuous("", formatter = "percent") : unused argument (formatter = "percent")` 

ない geom_bar()

誰かが私が間違っていたものを私に説明できます?そして、元の質問への更新された回答を投稿するかもしれませんか?ここで

答えて

0

は、今では"count"で、私は当時geom_barのデフォルトstat"identity"たと思い、その質問

library(ggplot2) 
library(scales) 
ggplot(x, aes(x = variable, y = value)) + 
geom_bar(stat = "identity") + 
scale_y_continuous(labels = scales::percent) + 
coord_flip() 

からのコードの更新版です。 scale_y_continuousには、引数formatterがもうありません。

DATA

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")