Load and prepare the data
require(googlesheets)
require(ggplot2)
gs <- gs_url("https://docs.google.com/spreadsheets/d/1i24xdXe-Ju71_jloXNHzpNbHAxniRe6P8ZKqRBhEWQ4/")
tourism <- gs_read(gs, literal=F)
summary(tourism)
## Country Population Area Total
## Length:30 Min. : 37340 Min. : 160 Min. : 0.10
## Class :character 1st Qu.: 2272298 1st Qu.: 43527 1st Qu.: 9.15
## Mode :character Median : 7203084 Median : 86120 Median : 28.80
## Mean :15082498 Mean :155827 Mean : 82.67
## 3rd Qu.:11131809 3rd Qu.:285601 3rd Qu.: 71.25
## Max. :81459000 Max. :551695 Max. :421.20
## NonResidents Residents TotalPop NonResidentsPop
## Min. : 0.10 Min. : 0.00 Min. : 0.7733 Min. : 0.2306
## 1st Qu.: 4.75 1st Qu.: 3.15 1st Qu.: 2.6909 1st Qu.: 1.0795
## Median : 13.00 Median : 16.60 Median : 4.7257 Median : 2.0100
## Mean : 38.13 Mean : 44.54 Mean : 6.2327 Mean : 4.1366
## 3rd Qu.: 36.88 3rd Qu.: 30.82 3rd Qu.: 6.3896 3rd Qu.: 3.4099
## Max. :267.70 Max. :300.00 Max. :20.9663 Max. :19.0829
## ResidentsPop TotalArea NonResidentsArea ResidentsArea
## Min. :0.000 Min. : 58.21 Min. : 16.25 Min. : 0.00
## 1st Qu.:1.056 1st Qu.: 103.99 1st Qu.: 44.53 1st Qu.: 50.51
## Median :1.735 Median : 544.68 Median : 231.94 Median : 152.48
## Mean :2.094 Mean : 1517.67 Mean : 1227.15 Mean : 290.25
## 3rd Qu.:3.278 3rd Qu.: 1003.95 3rd Qu.: 603.02 3rd Qu.: 372.04
## Max. :4.391 Max. :28164.56 Max. :26898.73 Max. :1595.94
iberia <- subset(tourism, Country == "Portugal" | Country == "Spain")
summary(iberia)
## Country Population Area Total
## Length:2 Min. :10427301 Min. : 92212 Min. : 55.6
## Class :character 1st Qu.:19430442 1st Qu.:195656 1st Qu.:147.0
## Mode :character Median :28433582 Median :299101 Median :238.4
## Mean :28433582 Mean :299101 Mean :238.4
## 3rd Qu.:37436723 3rd Qu.:402546 3rd Qu.:329.8
## Max. :46439864 Max. :505990 Max. :421.2
## NonResidents Residents TotalPop NonResidentsPop
## Min. : 36.5 Min. : 19.1 Min. :5.332 Min. :3.500
## 1st Qu.: 94.3 1st Qu.: 52.7 1st Qu.:6.267 1st Qu.:4.066
## Median :152.1 Median : 86.3 Median :7.201 Median :4.632
## Mean :152.1 Mean : 86.3 Mean :7.201 Mean :4.632
## 3rd Qu.:209.9 3rd Qu.:119.9 3rd Qu.:8.135 3rd Qu.:5.198
## Max. :267.7 Max. :153.5 Max. :9.070 Max. :5.764
## ResidentsPop TotalArea NonResidentsArea ResidentsArea
## Min. :1.832 Min. :603.0 Min. :395.8 Min. :207.1
## 1st Qu.:2.200 1st Qu.:660.3 1st Qu.:429.1 1st Qu.:231.2
## Median :2.569 Median :717.7 Median :462.4 Median :255.2
## Mean :2.569 Mean :717.7 Mean :462.4 Mean :255.2
## 3rd Qu.:2.937 3rd Qu.:775.1 3rd Qu.:495.8 3rd Qu.:279.3
## Max. :3.305 Max. :832.4 Max. :529.1 Max. :303.4
In absolute numbers
Total number of tourism nights
# TOTAL
g <- ggplot(data=tourism, aes(x=reorder(Country,Total, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=Total), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=Total), fill=c("green","red"), stat="identity") +
ylab("TOTAL tourism nights in millions")
Total number of nights by Non-Residents of the receiving country
# TOTAL Non.Residents
g <- ggplot(data=tourism, aes(x=reorder(Country,NonResidents, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=NonResidents), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=NonResidents), fill=c("green","red"), stat="identity") +
ylab("Total Non-Residents tourism nights in millions")
Total number of nights by Residents of the receiving country
# TOTAL Residents
g <- ggplot(data=tourism, aes(x=reorder(Country,Residents, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=Residents), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=Residents), fill=c("green","red"), stat="identity") +
ylab("Total Residents tourism nights in 2015")
Normalised by country Population
Number of nights normalised by country population
# Normalised to Country Population
g <- ggplot(data=tourism, aes(x=reorder(Country,TotalPop, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=TotalPop), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=TotalPop), fill=c("green","red"), stat="identity") +
ylab("Total tourism nights / Population in 2015")
Number of nights by Non-Residents normalised by country population
g <- ggplot(data=tourism, aes(x=reorder(Country, NonResidentsPop, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=NonResidentsPop), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=NonResidentsPop), fill=c("green","red"), stat="identity") +
ylab("Non-Residents tourism nights / Population in 2015")
Number of nights by Residents normalised by country population
g <- ggplot(data=tourism, aes(x=reorder(Country,ResidentsPop, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=ResidentsPop), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=ResidentsPop), fill=c("green","red"), stat="identity") +
ylab("Residents tourism nights / Population in 2015")
Normalised by country Area
Number of nights normalised by country Area
# Normalised to Country Area
g <- ggplot(data=tourism, aes(x=reorder(Country,TotalArea, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=TotalArea), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=TotalArea), fill=c("green","red"), stat="identity") +
ylab("Total tourism nights / Area in 2015") + scale_y_log10()
Number of nights by Non-Residents normalised by country Area
g <- ggplot(data=tourism, aes(x=reorder(Country, NonResidentsArea, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y= NonResidentsArea), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=NonResidentsArea), fill=c("green","red"), stat="identity") +
ylab("Non-Residents tourism nights / Area in 2015") + scale_y_log10()
Number of nights by Residents normalised by country Area
g <- ggplot(data=tourism, aes(x=reorder(Country,ResidentsArea, function(x)x))) + coord_flip() + xlab("Country")
g + geom_bar(aes(y=ResidentsArea), stat="identity") +
geom_bar(data=iberia, aes(x=Country, y=ResidentsArea), fill=c("green","red"), stat="identity") +
ylab("Residents tourism nights / Area in 2015") + scale_y_log10()
## Warning: Stacking not well defined when ymin != 0