小编sho*_*deh的帖子

错误:StatBin需要一个连续的x变量x变量是离散的.也许你想要stat ="count"?

我昨天运行这个代码但它运行今天运行后,我收到了这个错误.错误:StatBin需要一个连续的x变量x变量是离散的.也许你想要stat ="count"?

library(rattle)
dsname <- "weatherAUS"
ds <- get(dsname)
p <- ggplot(ds, aes(Location, fill=Location))
p <- p + geom_bar(width=1, colour="white")
p <- p + theme(legend.position="none")
p <- p + coord_flip()
p <- p + geom_text(stat="bin",
color="white",
hjust=1.0,
size=3,
aes(y=..count.., label=..count..))
Run Code Online (Sandbox Code Playgroud)

我想知道如何解决这个问题.

algorithm r

3
推荐指数
1
解决办法
6121
查看次数

重新排序水平

我想知道如何修改下面的代码,根据每个级别的年级频率对单元格进行重新排序.

Year      <- c(rep(c("2006-07", "2007-08", "2008-09", "2009-10"), each = 4))
Category  <- c(rep(c("A", "B", "C", "D"), times = 4))
Frequency <- c(168, 259, 226, 340, 216, 431, 319, 368, 423, 645, 234, 685, 166, 467, 274, 251)
Data      <- data.frame(Year, Category, Frequency)

library(dplyr)  
Data <- group_by(Data,Year) %>%
 mutate(pos = cumsum(Frequency) - (0.5 * Frequency))

library(ggplot2)
p <- ggplot(Data, aes(x = Year, y = Frequency)) +
  geom_bar(aes(fill = Category), stat="identity", show.legend = FALSE) +
  geom_text(aes(label = Frequency, y = pos), size …
Run Code Online (Sandbox Code Playgroud)

r ggplot2

1
推荐指数
1
解决办法
60
查看次数

标签 统计

r ×2

algorithm ×1

ggplot2 ×1