Quantcast
Channel: グラフ - 廿TT
Viewing all articles
Browse latest Browse all 123

貸借対照表のグラフ

$
0
0

特に理由はないけれど、コロプラの貸借対照表を図示してみた。

貸借対照表 | 業績・財務 | IR情報 | 株式会社コロプラ

f:id:abrahamcow:20160302030243p:plain

library(readxl)
dat_row <-read_excel("~/Downloads/colopl_financialdata_201512.xlsx",9,skip=1)
tmp <-dat_row[,-c(1,3:4)]
colnames(tmp)<-c("item","2013 1Q","2013 2Q","2013 3Q","2013 4Q","2014 1Q","2014 2Q","2014 3Q","2014 4Q","2015 1Q","2015 2Q","2015 3Q","2015 4Q","2016 1Q")library(dplyr)library(tidyr)
BS1 <-dplyr::filter(tmp,item=="資産合計"|item=="負債合計"|item=="純資産合計")%>%
  mutate(class = ifelse(item=="資産合計","Asset","Liability")) 
BS1_long <- gather(BS1,quantile,yen,-c(item,class)) %>%
  group_by(quantile,class)%>%
  mutate(pos=cumsum(yen)-yen/2)library(ggplot2)
theme_set(theme_classic(12,"HiraMaruProN-W4"))

ggplot(BS1_long)+
  geom_bar(aes(x=class,y=yen,fill=item),
           stat="identity",color="black",alpha=0.4,width=1)+
  facet_wrap(~quantile)+
  xlab(label="")

f:id:abrahamcow:20160302030307p:plain

itemflag <-cumsum(!is.na(dat_row[,1]))
gokeiflag <-sapply(dat_row[,3],function(x)grepl("合計",x))
naflag <- is.na(dat_row[,3])
Asset <-dat_row[itemflag==1&!gokeiflag&!naflag,c(3,17)]
Liabilities <-dat_row[itemflag==2&!gokeiflag&!naflag,c(3,17)]
Net_asset <-dat_row[itemflag==3&!gokeiflag&!naflag,c(3,17)]

BS2 <-bind_rows(data.frame(class="Asset",Asset),data.frame(class="Liabilities",Liabilities),data.frame(class="Liabilities",Net_asset))
colnames(BS2)<- c("class","item","yen")
BS2_posi <- dplyr::filter(BS2,yen>=0) %>%
  group_by(class) %>%
  mutate(pos=cumsum(yen)-yen/2)
BS2_nega <- dplyr::filter(BS2,yen<0) %>% 
  group_by(class) %>%
  mutate(pos=cumsum(yen)-yen/2)

ggplot()+
  geom_bar(data=BS2_posi,aes(x=class,y=yen,fill=item),colour="black",stat ="identity",alpha=0.4)+
  geom_bar(data=BS2_nega,aes(x=class,y=yen,fill=item),colour="black",stat ="identity",alpha=0.4)+
  theme(legend.position="none")+
  geom_text(data=BS2_posi,aes(x=class,y=pos,label=item))+
  geom_text(data=BS2_nega,aes(x=class,y=pos,label=item))+
  xlab("")+ylab("")library(grid)
quartzFonts(HiraMaru=quartzFont(rep("HiraMaruProN-W4",4)))
grid.gedit("GRID.text", grep=TRUE, global=TRUE, gp=gpar(fontfamily="HiraMaru"))


Viewing all articles
Browse latest Browse all 123

Trending Articles