-
Notifications
You must be signed in to change notification settings - Fork 0
/
systemair.r
222 lines (181 loc) · 7.79 KB
/
systemair.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
library(borsdata)
library(stringr)
library(dplyr)
# hämtar info genom borsdata
year<-fetch_year(221,key = key)
r12<-fetch_r12(221,key = key)
kvartal<-fetch_quarter(221,key = key)
# städar upp datan
for(i in 1:33){
year[,i]<-rev(year[,i])
r12[,i]<-rev(r12[,i])
kvartal[,i]<-rev(kvartal[,i])
}
# lägger in 2020 Q3 som ett eget år
year[11,]<-r12[10,]
library(ggplot2)
skr<-data.frame(year=year$year,revenue=year$revenues,
ebit=year$operating_Income,
ebit_marg=year$operating_Income/year$revenues)
cagr<-(year$revenues[11]/year$revenues[1])^(1/length(year$year))-1
plot_labels <- data.frame(label = round(cagr,digits = 3)*100,
x = seq(2010.5,2020.5,1),
y = year$revenues[1:11]*1.3/1000)
ggplot(data = skr, aes(x=year))+
geom_bar(stat = "identity",
fill = "dark green",
colour = "black", aes(y=skr$revenue/1000)) + theme_bw()+ labs(
x = "År",
y = "Omsättning\n MDR",
title = "Systemair omsättning och rörelsemarginal 2010-2020(R12)",
caption = "Källa: Börsdata"
)+
theme(
plot.title = element_text(hjust = 0.5)
)+ theme(
panel.grid.major.x =
element_blank(),
panel.grid.minor.x =
element_blank(),
panel.grid.major.y =
element_line(color = "grey"),
axis.title.y = element_text(face = "bold",size=14),
axis.title.x = element_text(face = "bold",size=14)
)+
scale_x_continuous(breaks=seq(2010,2020,1), labels = c(seq(2010,2019,1),"2020(R12)"))+
geom_text(data = plot_labels,
aes(x = 2016, y = 8.1,
label = paste("cagr:",label)), size=5, parse = TRUE, angle=17)+
annotate("segment", x = 2010, xend = plot_labels$x[10],
y = year$revenues[2]*1.1/1000,
yend = year$revenues[10]*1.2/1000,
arrow = arrow(length = unit(1, "lines")), colour = "grey50")+
geom_line(aes(y=round(skr$ebit_marg, digits=3)*100),colour="red", size=1.5) +
scale_y_continuous(limits = c(0,12), breaks = seq(0,12,2),
sec.axis = sec_axis(~.,
name = "Rörelsemarginal [%]",
labels=seq(0,12,2),
breaks = seq(0,12,2)))+
geom_hline(aes(yintercept=10), colour="red", linetype="dashed", size=1)+
geom_text(x = 2013, y = 10.5,
label = "Lönsamhetsmål", color="red", size=5, parse = TRUE)
#### Kvartal ####
skr<-read.csv("data_long.csv") # Använder en egen fil från Systemairs IR.
# Ändrar så att det står vilken period det gäller
skr$period<-str_replace_all(string = skr$period,pattern = "1","Q1 (maj-jul)")
skr$period<-str_replace_all(string = skr$period,pattern = "2","Q2 (aug-okt)")
skr$period<-str_replace_all(string = skr$period,pattern = "3","Q3 (nov-jan)")
skr$period<-str_replace_all(string = skr$period,pattern = "4","Q4 (feb-apr)")
library(tidyr)
ggplot(data = skr, aes(year, group=period))+
geom_bar(stat = "identity",
fill = "dark green",
position = "dodge",
colour = "black", aes(y=skr$revenue))+
geom_point(y=round(skr$ebit_marg, digits=3)*200,colour="red", size=3)+
theme_bw()+
theme(
plot.title = element_text(hjust = 0.5),
axis.title.y = element_text(face = "bold",size=14),
axis.title.x = element_text(face = "bold",size=14)
)+
scale_y_continuous(limits = c(0,2500), breaks = seq(0,2500,500),
sec.axis = sec_axis(~./200,
name = "Rörelsemarginal [%]",
labels=seq(0,12.5,2.5),
breaks = seq(0,12.5,2.5)))+
labs( x = "År",
y = "Omsättning\n MKR",
title = "Systemair omsättning & rörelsemarginal per kvartal",
caption = "Källa: Systemair IR")+
facet_grid(~period)
#### Lindab ####
# hämtar info genom borsdata
year<-fetch_year(127,key = key)
r12<-fetch_r12(127,key = key)
kvartal<-fetch_quarter(127,key = key)
# städar upp datan
for(i in 1:33){
year[,i]<-rev(year[,i])
r12[,i]<-rev(r12[,i])
kvartal[,i]<-rev(kvartal[,i])
}
# lägger in 2020 Q3 som ett eget år
year[11,]<-r12[10,]
skr<-data.frame(year=year$year,revenue=year$revenues,
ebit=year$operating_Income,
ebit_marg=year$operating_Income/year$revenues)
cagr<-(year$revenues[11]/year$revenues[1])^(1/length(year$year))-1
plot_labels <- data.frame(label = round(cagr,digits = 3)*100,
x = seq(2009.5,2019.5,1),
y = year$revenues[1:11]*1.3/1000)
ggplot(data = skr, aes(x=year))+
geom_bar(stat = "identity",
fill = "dark green",
colour = "black", aes(y=skr$revenue/1000)) + theme_bw()+ labs(
x = "År",
y = "Omsättning\n MDR",
title = "Lindab omsättning och rörelsemarginal 2009-2019",
caption = "Källa: Börsdata"
)+
theme(
plot.title = element_text(hjust = 0.5)
)+ theme(
panel.grid.major.x =
element_blank(),
panel.grid.minor.x =
element_blank(),
panel.grid.major.y =
element_line(color = "grey"),
axis.title.y = element_text(face = "bold",size=14),
axis.title.x = element_text(face = "bold",size=14)
)+
scale_x_continuous(breaks=seq(2009,2019,1), labels = seq(2009,2019,1))+
geom_text(data = plot_labels,
aes(x = 2013, y = 8.7,
label = paste("cagr:",label)), size=5, parse = TRUE, angle=12)+
annotate("segment", x = 2010, xend = plot_labels$x[10],
y = year$revenues[2]*1.1/1000,
yend = year$revenues[10]*1.13/1000,
arrow = arrow(length = unit(1, "lines")), colour = "grey50")+
geom_line(aes(y=round(skr$ebit_marg, digits=3)*100),colour="red", size=1.5) +
scale_y_continuous(limits = c(0,12), breaks = seq(0,12,2),
sec.axis = sec_axis(~.,
name = "Rörelsemarginal [%]",
labels=seq(0,12,2),
breaks = seq(0,12,2)))+
geom_hline(aes(yintercept=10), colour="red", linetype="dashed")+
geom_text(x = 2013, y = 10.5,
label = "Lönsamhetsmål", color="red", size=5, parse = TRUE)
### Kvartalsdata Lindab
skr<-data.frame(year=kvartal$year,period=kvartal$period,
revenue=kvartal$revenues,
ebit=kvartal$operating_Income,
ebit_marg=round(kvartal$operating_Income/kvartal$revenues*100,digits = 1))
skr$period<-str_replace_all(string = skr$period,pattern = "1","Q1 (jan-mar)")
skr$period<-str_replace_all(string = skr$period,pattern = "2","Q2 (apr-jun)")
skr$period<-str_replace_all(string = skr$period,pattern = "3","Q3 (jul-sep)")
skr$period<-str_replace_all(string = skr$period,pattern = "4","Q4 (okt-dec)")
library(tidyr)
ggplot(data = skr, aes(year, group=period))+
geom_bar(stat = "identity",
fill = "dark green",
position = "dodge",
colour = "black", aes(y=skr$revenue))+
geom_point(y=round(skr$ebit_marg, digits=3)*250,colour="red", size=3)+
theme_bw()+
theme(
plot.title = element_text(hjust = 0.5),
axis.title.y = element_text(face = "bold",size=14),
axis.title.x = element_text(face = "bold",size=14)
)+
scale_y_continuous(limits = c(0,3000), breaks = seq(0,3000,500),
sec.axis = sec_axis(~./250,
name = "Rörelsemarginal [%]",
labels=seq(0,12,1.5),
breaks = seq(0,12,1.5)))+
labs( x = "År",
y = "Omsättning\n MKR",
title = "Lindab omsättning & rörelsemarginal per kvartal",
caption = "Källa: Börsdata")+
facet_grid(~period)