Do this before class

Read chapters 11-13 in the book Exploratory Data Analysis with R.

During class

Election 2018

The file Class_files/2018_R_per_kommun.csv contains the results of the Swedish elections for Riksdagen in Swedish municipalities from valmyndigheten. Extract the columns containing results for the main seven parties (columns 5-12), rescale this matrix using scale and call the result X.

  • Compute the principal components of X using princomp and plot using biplot. Which parties seem to be most close/distant to SD in terms of municipal voting patterns?

  • Perform hierarchical clustering of both X and t(X) using hclust and plot the resulting object with plot (add suitable labels for the former using labels-option in plot).

  • The file Class_files/Kommungruppsindelning_2017.csv contains a classification of Swedish municipalities (english translation). Join this with the election data (paste the first two columns of election data for a matching key).

  • Compute the singular value decomposition of X and extract the first two columns of the U matrix. Add these columns to the joined table above and plot them as points colored by the classification of municipalities. Does there seem to be a relation between voting patterns and classification (or do the points seem colored randomly)?

6 graders

In the file Class_files/betyg.csv you will find the average grade of 6 graders in a number of subjects and municipalities. Data are taken from SCB and are provided by Skolverket - a detailed description of the data is available from SCB. Explore the data using multivariate techniques.