ggplot2中位置闪避错误

use*_*747 2 r bar-chart ggplot2

我目前正面临使用ggplot2的错误.我想使用此数据框创建一个标准错误栏的条形图:

       mean        se       pattern quality
1 54.955357 19.792315        spread    good
2 54.506944 18.580981       clumped    good
3 29.604167 14.937291 centered good    good
5 23.300595 14.336305        spread     bad
6  8.371528  5.960366       clumped     bad
7 16.364583 11.525207 centered good     bad
8  7.062500 11.125915  centered bad     bad
Run Code Online (Sandbox Code Playgroud)

我使用这个公式来创建我的条形图:

ggplot(table, aes(x=pattern, y=mean, fill=quality))+
geom_bar(position="dodge")+
geom_errorbar(aes(ymin=mean-se, ymax=mean+se, 
                  width=0.2, position=position_dodge(0.9)))
Run Code Online (Sandbox Code Playgroud)

但是当我运行它时,应该有我的条形图的窗口显示为空白,并弹出此错误消息

Don't know how to automatically pick scale for object of type proto/environment. Defaulting to continuous
Error : Aesthetics must either be length one, or the same length as the dataProblems:position_dodge(0.9)
Run Code Online (Sandbox Code Playgroud)

当我尝试在没有position=position_dodge(0.9)条形图的情况下运行它时,条形图位于每个手段之间而不是中间位置.

我已经尝试了几个价值dodge和其他的东西,但我已经没有想法了.

Dan*_*iel 5

我收到一条警告:"stat_identity"(映射到value,而不是count)已应用.要阻止该警告,只需添加stat="identity"到geom.

te <- c("val mean se pattern quality", 
    "1 54.955357 19.792315 spread good", 
    "2 54.506944 18.580981 clumped good",
    "3 29.604167 14.937291 centered_good good",
    "5 23.300595 14.336305 spread bad",
    "6 8.371528  5.960366 clumped bad",
    "7 16.364583 11.525207 centered_good bad",
    "8 7.062500 11.125915 centered_bad bad")

df <- read.table(text=te, header=T)

require(ggplot2)

ggplot(df, aes(x=pattern, y=mean, fill=quality))+
  geom_bar(position="dodge", stat="identity")+
  geom_errorbar(aes(ymin=mean-se, ymax=mean+se), 
            width=0.2, position=position_dodge(0.9))
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述