Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R ggplot2:对打印进行排序-更新_R_Ggplot2 - Fatal编程技术网

R ggplot2:对打印进行排序-更新

R ggplot2:对打印进行排序-更新,r,ggplot2,R,Ggplot2,我遇到了,因为我有同样的问题。然而,即使是他的MWE也不适合我;我要么得到: Error: stat_count() must not be used with a y aesthetic 当我包括geom\u bar() 或 当我包括scale\u y\u continuous(“,formatter=“percent”) 但不是geom\u bar() 有人能解释一下我做错了什么吗?或者发布原始问题的更新答案?以下是该问题代码的更新版本 library(ggplot2) library(s

我遇到了,因为我有同样的问题。然而,即使是他的MWE也不适合我;我要么得到:

Error: stat_count() must not be used with a y aesthetic
当我包括
geom\u bar()

当我包括
scale\u y\u continuous(“,formatter=“percent”)

但不是
geom\u bar()


有人能解释一下我做错了什么吗?或者发布原始问题的更新答案?

以下是该问题代码的更新版本

library(ggplot2)
library(scales)
ggplot(x, aes(x = variable, y = value)) + 
geom_bar(stat = "identity") +
scale_y_continuous(labels = scales::percent) + 
coord_flip() 
我猜当时
geom\u bar
中默认的
stat
“identity”
,现在是
“count”
scale\u y\u continuous
不再具有参数
formatter

数据

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

x以下是该问题代码的更新版本

library(ggplot2)
library(scales)
ggplot(x, aes(x = variable, y = value)) + 
geom_bar(stat = "identity") +
scale_y_continuous(labels = scales::percent) + 
coord_flip() 
我猜当时
geom\u bar
中默认的
stat
“identity”
,现在是
“count”
scale\u y\u continuous
不再具有参数
formatter

数据

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