Skip to content

Posts tagged ‘ggplot2’

Using R to Analyse Tourism Data – Part 1: Visualising Tourist Profile


Tourism is an important sector in the global economy. In many countries, tourism is the main source of revenue, Thailand is one of them. However, tourism sector is a fast moving sector. It is very sensitive to various factors and also vulnerable. The tourism markets for each destination (country) are also very diverse. Tourism data are available and updated frequently. One of the most important report of national tourism statistics; number of tourist arrivals from each country of origin, their average length of stay and total receipt or expenditure. These tourism statistics are important but often reported separately due to the limitation of software used by analysts.

The following graph represents profile of international tourists in Thailand in 2005.

The picture above was produced in R with package ‘ggplot2’ using the code below.


# Step 1: Import data into R
exp05 <- read.csv("http://dl.dropbox.com/u/46344142/thai_tour_2005.csv", head = T)
# Step 2: Load 'ggplot2' package for plotting elegent data visualisation
library(ggplot2)
# Step 3: Specify x and y axis, label, size of the bubbles and colour of the region
exp <- ggplot(exp05, aes(x=number, y=length, label=country, size=receipt, colour = region))
# Step 4: Create a plot and add texts to x and y axis
exp + geom_point() + geom_text(hjust=0.7, vjust=2) + labs(x = "Number of Tourist Arrivals", y = "Length of Stay (days)") + scale_area("Receipt (M. USD)") + scale_colour_hue("Region")

%d bloggers like this: