First, go to Statistics Canada Table 18-10-0004-01 (formerly CANSIM 326-0020)https://www150.statcan.gc.ca/t1/tbl1/en/tv.action?pid=1810000401. Download the all-items monthly Consumer Price Index for Quebec, Ontario, Alberta, and BC, January 2010 to June2020. Calculate the 12 month inflation rates (you will lose January 2010 to December 2010 in the process). Clean the Excel file so that it is structured like a normal wide-format data frame with four variables, the date, and the inflation rate for each of the four provinces. Save it as a.csv file.
1. Read the file and print the first six and last six observations.
2. Write a function to calculate the coefficient of variation as per equation 1.8 in the lecture notes.
3. Reshape the data into long format using the melt function, and rename value to be“inflation” and variable to be “province”. Print the first six observations.
4. Use the aggregate function to create a table of mean, median, and coefficient of variation, for the four provinces.
5. From the four-province inflation data use ggplot2 to produce a time series chart with the four provincial inflation rates plotted against Date, by modifying the code on page42 of the notes.
6. Repeat #5, but this time change the geom from line to point with size 1.5 for all provinces but BC, and change the theme from theme_economist() to theme().
Next, go to Statistics Canada 14-10-0023-01 (formerly CANSIM 282-0008)https://www150.statcan.gc.ca/t1/tbl1/en/cv.action?pid=1410002301. Download the annual total, all industries, both sexes, 15 yrs and over unemployment rate for Newfoundland and Labrador,Quebec, Ontario, Alberta, and BC, 2000 to 2019. Clean the Excel file so that it is structured like a normal wide-format data frame with six variables, the year, and the unemployment rate for each of the five provinces. Save it as a .CSV file.
7. Read the file and print the first six and last six observations.
8. Create a scatterplot matrix for the unemployment rates in the five provinces.
9. Create side-by-side boxplots of unemployment rates in the five provinces.
10. Create side-by-side beanplots of unemployment rates in the five provinces.