yuan_valuation = CNY_raw * 100,
dollar_adj_valuation = USD_adjusted * 100,
euro_adj_valuation = EUR_adjusted * 100,
sterling_adj_valuation = GBP_adjusted * 100,
yen_adj_valuation = JPY_adjusted * 100,
yuan_adj_valuation = CNY_adjusted * 100
), by=date]
dates = data$date %>% unique
# Create data file in Excel
# Instead of writing one page per delivery (date), this line creates a file with a single tab in Excel
write_xlsx(data, path = "output-data/bigmac_01_2019.xlsx")
# Create tidy data (RDS) to produce visualizations in Shiny
data <- data %>%
gather(key = "measure", value="value", -c(date, Country, iso_a3, currency_code)) %>%
saveRDS(file = "summarizedData.rds")
rm(list = ls())
summarizedData <- readRDS("C:/Users/victo/Desktop/bigMacIndex/summarizedData.rds")
View(summarizedData)
thisView <- summarizedData %>% filter(measure=="dollar_valuation")
thisView <- summarizedData %>% filter(measure=="dollar_valuation", Country=="Mexico") %>% group_by(year(date)) %>% summarise(mean(value, na.rm = TRUE))
View(thisView)
thisView <- summarizedData %>% filter(measure=="dollar_valuation", Country=="Mexico") %>% group_by(year(date)) %>% summarise(AVERAGE = mean(value, na.rm = TRUE))
thisView <- summarizedData %>% filter(measure=="dollar_valuation", Country=="Mexico") %>% group_by(year(date)) %>% summarise(AVERAGE_MEXICO = mean(value, na.rm = TRUE))
library(ggplot2)
library(dplyr)
library(tidyr)
summarizedData <- readRDS("summarizedData.rds")
rm(list = ls())
library(ggplot2)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(year(date)) %>%
summarise(AVERAGE_MEXICO = mean(value, na.rm = TRUE))
ggplot(averageForMexico) + geom_point()
View(summarizedData)
View(averageForMexico)
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = year(date)) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
View(averageForMexico)
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) + geom_point()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_jitter()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point()
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = year(date)) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point()
library(ggthemes)
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
theme_economist()
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth() +
theme_economist()
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
theme_economist()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
theme_solarized()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
theme_wsj()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
theme_wsj()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top")
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top", labels())
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top", labels=TRUE)
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top", labels=abbreviate)
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top")
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
theme_few()
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
theme_few()
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
theme_few()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete() +
theme_few()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
theme_few()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
theme_economist()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
coord_flip() +
theme_economist()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
coord_fixed() +
theme_economist()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
coord_cartesian() +
theme_economist()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_smooth(se=FALSE) +
scale_x_discrete(position = "top") +
coord_cartesian()
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_bar() +
scale_x_discrete(position = "top") +
coord_cartesian()
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_bar()
ggplot(averageForMexico, aes(x=factor(YEAR)) +
geom_bar()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR))) +
geom_bar()
# plot
ggplot(averageForMexico, aes(x=YEAR)) +
geom_bar()
# plot
ggplot(averageForMexico, aes(x=YEAR)) +
geom_col()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR))) +
geom_col()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR))) +
geom_point()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
geom_text(aes(angle=45))
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
theme_wsj()
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
scale_x_date() +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
scale_x_discrete() +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point() +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point(size=2) +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE)) +
geom_point(size=3) +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=3) +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(x = "AÑO")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_wsj() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist_white() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "down") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
# plot
ggplot(averageForMexico, aes(x=factor(YEAR), y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)")
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)") +
labs(x = "Año")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right",
legend.title = "h") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)") +
labs(x = "Año")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)") +
labs(x = "Año")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right",
legend.title = FALSE) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)") +
labs(x = "Año")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right") +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)") +
labs(x = "Año")
library(ggplot2)
library(ggthemes)
library(dplyr)
library(tidyr)
# Get summarized data
summarizedData <- readRDS("summarizedData.rds")
# Calculate average for Mexico
averageForMexico <- summarizedData %>%
filter(measure=="dollar_valuation", Country=="Mexico") %>%
group_by(YEAR = as.factor(year(date))) %>%
summarise(AVERAGE = mean(value, na.rm = TRUE))
# plot
ggplot(averageForMexico, aes(x=YEAR, y=AVERAGE, col=AVERAGE)) +
geom_point(size=5) +
scale_x_discrete(position = "top") +
theme_economist() +
theme(axis.text.x = element_text(angle = 90, hjust = 1),
legend.position = "right",
legend.title = element_blank()) +
labs(title = "México: sobrevaluación promedio (anual).") +
labs(y = "Sobrevaluación (%)") +
labs(x = "Año")
