---
title: "Macroeconomic Dashboards"
author: 'Marcos J Ribeiro'
output:
flexdashboard::flex_dashboard:
orientation: rows
social: [ "twitter", "facebook", "linkedin", "menu" ]
source_code: embed
vertical_layout: scroll
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(haven)
library(plyr)
library(plotly)
```
```{r include=FALSE}
df <- read_dta("happy.dta")
attach(df)
f1 = df[year>2010, ]
f2 = df[year==2011, ]
```
PAGE 1
======================================================================
Row
-----------------------------------------------------------------------
### Chart A
```{r echo=FALSE}
g15 = ggplot(data = f2, aes(x=lld, y=ppc/10000))+
ylim(-0.001, 10.2) +
geom_smooth(method = 'lm',formula = y~x, color='black', se=F) +
geom_text(aes(label=CountryCode), size=4)
g16 = g15 +
ggtitle('GDP per capita and Life Satisfaction') +
xlab('Life Satisfaction') +
ylab('GDP per capita') +
theme(axis.title.x = element_text(colour = 'black', size=13),
axis.title.y = element_text(colour = 'black', size=13),
plot.title = element_text(hjust = 0.5))
ggplotly(g16)
```
### Chart B
```{r echo=FALSE}
f2 = df[(year==2015)&(ppc/10000>=0.08)&(rendacod==1|rendacod==4), ]
g9 = ggplot(data = f2, aes(x=hc, y=ppc/10000))+
ylim(-0.001, 10.2) +
geom_smooth(method = 'lm',formula = y~x, color='black', se=F) +
geom_text(aes(label=CountryCode), size=4)
g10 = g9 +
ggtitle('GDP per capita and HC') +
xlab('Human capital') +
ylab('GDP per capita') +
theme(axis.title.x = element_text(colour = 'black', size=13),
axis.title.y = element_text(colour = 'black', size=13),
plot.title = element_text(hjust = 0.5))
ggplotly(g10)
```
ROW
-----------------------------------------------------------------------
### Chart C
```{r echo=FALSE}
##### PPC and Institutional quality
g11 = ggplot(data = f2, aes(x=qinst, y=ppc/10000))+
geom_smooth(method = 'lm',formula = y~x, color='black', se=F) +
geom_text(aes(label=CountryCode), size=4)
g12 = g11 +
ggtitle('GDP per capita and Institutional Quality') +
xlab('Institutional Quality') +
ylab('GDP per capita') +
theme(axis.title.x = element_text(colour = 'black', size=13),
axis.title.y = element_text(colour = 'black', size=13),
plot.title = element_text(hjust = 0.5))
ggplotly(g12)
```
### Chart D
```{r echo=FALSE}
##### PPC and population growth
g13 = ggplot(data = f2, aes(x=crespop, y=ppc/10000))+
xlim(-0.009, 0.04) +
geom_smooth(method = 'lm',formula = y~x, color='black', se=F) +
geom_text(aes(label=CountryCode), size=4)
g14 = g13 +
ggtitle('GDP per capita and Population Growth') +
xlab('Population Growth') +
ylab('GDP per capita') +
theme(axis.title.x = element_text(colour = 'black', size=13),
axis.title.y = element_text(colour = 'black', size=13),
plot.title = element_text(hjust = 0.5))
ggplotly(g14)
```