-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrough work.R
81 lines (57 loc) · 1.96 KB
/
rough work.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
total_prod_year <- continents %>%
group_by(Year) %>%
summarise(total_production = sum(production))
p <- total_prod_year %>%
ggplot(aes(x = Year, y=total_production ))+
geom_line(color = "steelblue",linewidth = 1)+
geom_point(color = "red")+
labs(title = "Global Production",
x = "Year",
y = "Production (Metric Tons)",
caption = "Source:Ourworldindata.org"
)+
theme( plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
axis.title = element_text(size = 12),
axis.text = element_text(size = 10))
q <- continents %>%
ggplot(aes(x = Year,y = production, colour = Entity))+
geom_line(size = 1)+
labs(title = "Trends in Beans Production Across Continents ",
x = "Year",
y = "Production (Metric Tons)",
color = "Continent"
)+
theme(
plot.title = element_text(hjust = 0.5, size = 14, face = "bold"),
plot.subtitle = element_text(hjust = 0.5, size = 12),
legend.position = "right",
axis.title = element_text(size = 12),
axis.text = element_text(size = 10)
)
k <- countries %>%
group_by(Entity) %>%
summarise(Total_production = sum(production)) %>%
slice_max(order_by = Total_production, n= 5) %>%
ggplot(aes(x = reorder(Entity,Total_production),y = Total_production,fill = Entity))+
geom_col(show.legend = FALSE)+
coord_flip()+
labs(
title = "Top 5 Beans Producing Countries",
x = "Country",
y = "Total Production (Metric Tons)"
)+
theme( plot.title = element_text(hjust = 0.5, size = 14, face = "bold"))
m <- continents %>%
ggplot(aes(x = Year,y = Entity,fill = production))+
geom_tile()+
scale_fill_viridis_c(option = "viridis")+
labs(title = "Regional Production",
x = "Year",
y = "Region",
fill = "Production"
)+
theme( plot.title = element_text(hjust = 0.5, size = 14, face = "bold"))
library(patchwork)
(p + q)
q + m
p+ m