R ggplot不显示数据

R ggplot不显示数据,r,plot,ggplot2,dataframe,R,Plot,Ggplot2,Dataframe,我正试图用ggplot制作一个漂亮的情节。但是,我不知道为什么它没有显示数据 这里有一些最低限度的代码 dummylabels <- c("A","B","C") dummynumbers <- c(1,2,3) dummy_frame <- data.frame(dummylabels,dummynumbers) p= ggplot(data=dummy_frame, aes(x =dummylabels , y = dummynumbers)) + geom_bar(fil

我正试图用ggplot制作一个漂亮的情节。但是,我不知道为什么它没有显示数据

这里有一些最低限度的代码

dummylabels <- c("A","B","C")
dummynumbers <- c(1,2,3)
dummy_frame <- data.frame(dummylabels,dummynumbers)
p= ggplot(data=dummy_frame, aes(x =dummylabels , y = dummynumbers)) + geom_bar(fill = "blue") 
p + coord_flip() + labs(title = "Title")

为什么会出现此错误?

从您收到的错误消息中:

如果希望y表示数据中的值,请使用stat=“identity”

geom_bar预计将用作直方图,它将数据本身存储起来,并根据频率计算高度。这是默认的
stat=“bin”
行为。它会抛出一个错误,因为您也给了它一个y值。要修复它,您需要
stat=“identity”


p欢迎来到SO!错误本身是这样说的:)您映射到变量
y
=>您希望从数据中获得“原始”y值,但是
stat=“bin”
生成计数而不是“原始”数据,因此存在概念冲突。
Error : Mapping a variable to y and also using stat="bin".
  With stat="bin", it will attempt to set the y value to the count of cases in each group.
  This can result in unexpected behavior and will not be allowed in a future version of ggplot2.
  If you want y to represent counts of cases, use stat="bin" and don't map a variable to y.
  If you want y to represent values in the data, use stat="identity".
  See ?geom_bar for examples. (Defunct; last used in version 0.9.2)
p <- ggplot(data = dummy_frame, aes(x = dummylabels, y = dummynumbers)) +
            geom_bar(fill = "blue", stat = "identity") +
            coord_flip() + 
            labs(title = "Title")
p