Just the code.
Load the necessary packages.
require(dplyr)
require(ggplot2)
Creating dataframe.
Manipur <- data.frame("Year" = 2006:2014,
"Domestic" = c(120472, 101000, 115300, 127524, 116652, 134505,
134541, 140673, 143059),
"Foreign" = c(263, 460, 271, 405, 431, 578, 749, 1908, 2588))
Manipur
## Year Domestic Foreign
## 1 2006 120472 263
## 2 2007 101000 460
## 3 2008 115300 271
## 4 2009 127524 405
## 5 2010 116652 431
## 6 2011 134505 578
## 7 2012 134541 749
## 8 2013 140673 1908
## 9 2014 143059 2588
Changing the Year variable into factor and add another variable call Total to get the total tourist inflow.
str(Manipur)
## 'data.frame': 9 obs. of 3 variables:
## $ Year : int 2006 2007 2008 2009 2010 2011 2012 2013 2014
## $ Domestic: num 120472 101000 115300 127524 116652 ...
## $ Foreign : num 263 460 271 405 431 ...
Manipur$Year <- as.factor(Manipur$Year)
Manipur <- mutate(Manipur, Total = Domestic + Foreign)
Manipur
## Year Domestic Foreign Total
## 1 2006 120472 263 120735
## 2 2007 101000 460 101460
## 3 2008 115300 271 115571
## 4 2009 127524 405 127929
## 5 2010 116652 431 117083
## 6 2011 134505 578 135083
## 7 2012 134541 749 135290
## 8 2013 140673 1908 142581
## 9 2014 143059 2588 145647
Subsetting only Year and Total tourist inflow to plot.
total.inflow <- select(Manipur, Year, Total)
total.inflow
## Year Total
## 1 2006 120735
## 2 2007 101460
## 3 2008 115571
## 4 2009 127929
## 5 2010 117083
## 6 2011 135083
## 7 2012 135290
## 8 2013 142581
## 9 2014 145647
Plotting
ggplot(total.inflow, aes(x = Year, y = Total, group = 1)) +
geom_line(color = "red", size = 2) +
labs( x = "", y = "") +
theme(axis.text = element_text(face = "bold", size = 12,
family = "Comic Sans")) +
ggtitle("Tourist inflow in Manipur") +
theme(plot.title = element_text(hjust = 0, size = rel(3)))