[英]How could I bar_plot this data.frame?
vertejumi_ceturksnos <- data.frame(
Vertejumi = c("0", "1", "2", "3"),
Pirmais = c(Pirmaiss),
Otrais = c(Otraiss),
Tresais = c(Tresaiss),
Ceturtais = c(Pirmaiss)
)
我想用這些值制作一個條形圖,所以 x 軸 <- 與 values("Pirmais","Otrais","Tresais","Ceturtais") <- 對應於一年中的季度和 y 軸進行比較<- 有條形達到表中的金額,金額對應於第一列中的 0:3 值
試試這個,如果您的數據格式與圖像相同並且我理解這個問題,應該可以工作。
library(tidyr)
library(ggplot2)
vertejumi_ceturksnos %>%
pivot_longer(cols = -Vertejumi) %>%
ggplot(aes(x = factor(name,
levels = c("Primais",
"Otrais",
"Tresais",
"Ceturtais")),
y = value,
fill = Vertejumi))+
geom_bar(stat = "identity")+
labs(x = "x label", y = "y label")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.