-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path00_dashboard.Rmd
295 lines (217 loc) · 7.15 KB
/
00_dashboard.Rmd
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
---
title: "재무제표 시각화"
output:
flexdashboard::flex_dashboard:
orientation: columns
fig.height: 5
---
```{r setup, include=FALSE}
# 라이브러리, 데이터셋 로드
library(flexdashboard)
library(tidyverse)
library(DT)
library(treemap)
library(plotly)
BS <- read_tsv("dataset/01_bs.tsv", trim_ws = FALSE)
PL <- read_tsv("dataset/02_pl.tsv", trim_ws = FALSE)
CF <- read_tsv("dataset/03_cf.tsv", trim_ws = FALSE)
```
# Overview
### INTRO
#### 들어가며
인류는 물물교환을 통해 사회를 이루어 왔다. 처음에는 물건을 교환하는 것만으로도 좋았지만, 거래를 위해 물건을 운반하고 보관하는 일에 한계를 느꼈다. 사람들은 돈을 발명했고 이를 주고 받기 시작했다. 이로 인해 과거에는 상상할 수 없는 거래가 이루어 졌다. 하지만 돈이 등장하면서 온갖 불만족이 쏟아져 나왔다. 물리적인 거래가 논리적으로 변하면서, 거래의 복잡성이 쏟아져 나왔다.
#### 회계의 탄생
거래의 복잡성이 인간의 감당 범위를 넘어서는 그 때, 회계가 생겼다. 특정기간동안 돈을 잃고 버는 것을 넘어 거래를 단순하게 정리정돈 하게 되었고, 다시 인류는 성장할 수 있게 되었다. 회계란 나의 재산과 거래를 관리하고 그 결과를 누구나 쉽게 이해하는 방법으로 공유하기 위해 태어났다. 그런데 그 공유 방법에 문제가 생겼다.
#### 회계기준
수많은 문제 중 하나는 의사소통이다. 거래를 장부에 기록할 때 사람마다 다른 표현을 쓰다 보니 의사소통 비용이 기하급수적으로 증가하기 시작했다. 이런 문제를 해결하기 위해 등장한 것이 회계기준이다. 회계기준은 "회계를 이렇게 기록합시다" 라고 약속한 기준이다. 현금, 빌려준돈, 받을돈, 재료비와 같이 장부상의 항목의 이름과 처리방법을 통일한 것을 계정과목이라고 한다.
#### 한걸음 더 나아가며
그럼에도 불구하고, 회계는 복잡하고 어렵게 느껴진다. 계정과목 개수도 많고 표만 봤을 때 그 의미를 쉽게 분석하기 어렵다. 일정 수준의 훈련을 받고 재무제표의 틀에 익숙해져야 의미를 파악할 수 있다.
이번 발표에서는 세상이 돌아가는 원리를 요약하여 전달하는 "회계" 정보를 시각화한다. 거래 정보를 표현하는 방식인 텍스트를 넘어 시각화로 표현해본다. 회계의 데이터는 기업공시 사이트인 DART 의 "삼성전자" 2018년 결산 재무제표 중 재무상태표, 손익계산서, 현금흐름표를 이용하였다.
```{r}
```
# 재무상태표
```{r}
ALL <- BS %>%
select(1,6,7,8,3)
ASSET_ <- BS %>%
filter(is.na(DEPTH_3) == FALSE) %>%
filter(DEPTH_1 == "자산") %>%
select(1,6,7,8,3)
DEBT_ <- BS %>%
filter(is.na(DEPTH_3) == FALSE) %>%
## filter(DEPTH_1 == "부채") %>%
filter(DEPTH_1 != "자산") %>%
select(1,6,7,8,3)
CAPITAL_ <- BS %>%
filter(is.na(DEPTH_3) == FALSE) %>%
filter(DEPTH_1 == "자본") %>%
select(1,6,7,8,3)
PL_ <- PL %>%
gather(key = "YEAR", value="VALUE", -ACC_NM, -ID ) %>%
arrange(ID, desc(YEAR), ACC_NM) %>%
mutate(ACC_NM = factor(ACC_NM, levels = PL %>% arrange(desc(ID)) %>% pull(ACC_NM) ))
```
Column {data-width=400}
-------------------------------------
### 표 {data-height=600}
```{r}
# 재무상태표
knitr::kable(BS[2:5])
```
### 부채와 자본 비 {data-height=400}
```{r}
asset_total <- BS %>%
filter(ACC_NAME == "자산") %>%
select(3) %>%
pull(1)
debt_total <- BS %>%
filter(ACC_NAME == "부채") %>%
select(3) %>%
pull(1)
capital_total <- BS %>%
filter(ACC_NAME == "자본") %>%
select(3) %>%
pull(1)
pie_df <- data.frame(
group = c("ASSET", "DEBT", "CAPITAL"),
value = c(asset_total, debt_total, capital_total)
)
options( scipen = 1000 )
pie <- ggplot(pie_df, aes(x="", y=value, fill=group))+
geom_bar(width = 1, stat = "identity")+
coord_polar("y", start=0) + scale_fill_brewer("Blues") +
theme(axis.text.x=element_blank())
pie
```
Column {data-width=300}
-------------------------------------
### 차변 | 자산
```{r fig.height = 14, fig.width = 8}
treemap(
ASSET_,
index=c("DEPTH_1","DEPTH_2","DEPTH_3"),
vSize="제 50 기",
vColor="제 50 기",
type="value",
height=100,
format.legend = list(scientific = FALSE, big.mark = " "),
fontfamily.title = "AppleGothic",
fontfamily.labels = "AppleGothic",
fontfamily.legend = "AppleGothic",
fontsize.title = 25,
fontsize.labels = 23,
fontsize.legend = 12,
sortID = "ACC_CD",
lowerbound.cex.labels = 0,
align.labels = list(c("center", "center"),c("left","top"),c("right", "bottom"))
)
```
Column {data-width=300}
-------------------------------------
### 대변 | 부채와 자본
```{r fig.height = 14, fig.width = 8}
treemap(
DEBT_,
index=c("DEPTH_1","DEPTH_2","DEPTH_3"),
vSize="제 50 기",
vColor="제 50 기",
type="value",
height=30,
format.legend = list(scientific = FALSE, big.mark = " "),
fontfamily.title = "AppleGothic",
fontfamily.labels = "AppleGothic",
fontfamily.legend = "AppleGothic",
fontsize.title = 25,
fontsize.labels = 23,
fontsize.legend = 12,
sortID = "-ACC_CD",
lowerbound.cex.labels = 0,
align.labels = list(c("center", "center"),c("left","top"),c("right", "bottom"))
)
```
```{r fig.height = 6, fig.width = 8}
### 자본
# treemap(
# CAPITAL_,
# index=c("DEPTH_2","DEPTH_3"),
# vSize="제 50 기",
# vColor="제 50 기",
# type="value",
# height=70,
# format.legend = list(scientific = FALSE, big.mark = " "),
# fontfamily.title = "AppleGothic",
# fontfamily.labels = "AppleGothic",
# fontfamily.legend = "AppleGothic",
# fontsize.title = 25,
# fontsize.labels = 23,
# fontsize.legend = 12,
# sortID = "ACC_CD",
# lowerbound.cex.labels = 0
# )
```
# 손익계산서
Column {data-width=400}
-------------------------------------
### 표
```{r}
knitr::kable(PL)
```
Column {data-width=600}
-------------------------------------
### 그래프
```{r}
PL_ %>% plot_ly(x= ~VALUE, y= ~ACC_NM, color= ~YEAR, orientation = 'h')
```
# 현금흐름표
Column {data-width=400}
-------------------------------------
### 표
```{r}
knitr::kable(CF)
```
Column {data-width=600}
-------------------------------------
### 현금흐름
```{r}
library(plotly)
library(rjson)
library(tidyverse)
NODE <- read_tsv("dataset/node.tsv")
EDGE <- read_tsv("dataset/edge.tsv")
p <- plot_ly(
type = "sankey",
domain = list(
x = c(0,1),
y = c(0,1)
),
orientation = "h",
valueformat = ".0f",
valuesuffix = "백만",
node = list(
# label = json_data$data[[1]]$node$label,
# color = json_data$data[[1]]$node$color,
label = NODE$label,
pad = 15,
thickness = 15,
line = list(
color = "black",
width = 0.5
)
),
link = list(
source = EDGE$source_idx,
target = EDGE$target_idx,
value = EDGE$value,
label = EDGE$label
)
) %>%
layout(
title = "CASH FLOW 2018. samsung Electronics",
font = list(
size = 10
),
xaxis = list(showgrid = F, zeroline = F),
yaxis = list(showgrid = F, zeroline = F)
)
p
```