當我進行以下操作時,我只想比較三年而不是總結它們。即使我沒有告訴它這樣做,實際的代碼也會對它們進行求和。有什么線索嗎?
hoteles <- tibble::tribble(
~Hotel , ~A?o, ~Ingresos
, "Hawaiian Club" , "1993", 450000
, "Hawaiian Club" , "1994", 475000
, "Hawaiian Club" , "1995", 390000
, "French Riviera", "1993", 225000
, "French Riviera", "1994", 240000
, "French Riviera", "1995", 205000
, "Bahamas Beach" , "1993", 245000
, "Bahamas Beach" , "1994", 255000
, "Bahamas Beach" , "1995", 345000
)
g <- ggplot(hoteles, aes(fill=A?o, y=Ingresos, x=reorder(Hotel, Ingresos)))
geom_bar(position="stack", stat="identity")
ggtitle("Ingresos por a?o por hotel")
labs(y = "Ingresos", x = "Hotel")
g

uj5u.com熱心網友回復:
你需要這樣的東西:
ggplot(hoteles, aes(fill=A?o, y=Ingresos, x=reorder(Hotel, Ingresos)))
geom_col(position="dodge")
ggtitle("Ingresos por a?o por hotel")
labs(y = "Ingresos", x = "Hotel")
scale_y_continuous(labels = scales::comma)

轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/407014.html
標籤:
