Setup and import

knitr::opts_chunk$set(echo = TRUE, fig.width=8, fig.height=5)
knitr::opts_knit$set(root.dir = "C:/Users/Peter/Documents/GU/data/som/")
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(rio)
library(ggplot2)
library(RColorBrewer)
theme_set(theme_bw())

# Läs in Super-SOM.
if(file.exists("supersom.RData"))
{ 
  print("Load RData")
  load("supersom.rdata")
} else {
  print("Import")
  system.time(supersom <- import("supersom/SND0905_SuperRSOM_v5.sav"))
  print("Saving RData")
  save.image(file="supersom.rdata")
}
## [1] "Load RData"
# Recode rank variable into binary categorical factor.
dummy <- function(x, one=c(1, 2, 3, 4), zero=c(6, 7), labels=c("Daily/weekly", "Never/seldom"))
{
  newx <- NA
  newx[x %in% one]  <- 1
  newx[x %in% zero] <- 0
  newx <- factor(newx, levels=c(1, 0), labels=labels)
  return(newx)
}

Recode Super-SOM 1986-2015

In general:

  • Daily/weekly is defined as at least 1 time per week.
  • Never/seldom is defined as less than 1 time per week.
# Demography.
supersom$ideology <- supersom$ba10       # Self-reported political left/right placement 1-5.
supersom$ideology[supersom$ideology >= 98] <- NA
supersom$polinterest <- supersom$ca10 %>% recode("1"="4", "2"="3", "3"="2", "4"="1") %>% as.numeric()
supersom$polinterest <- factor(supersom$polinterest, levels=c(1, 2, 3, 4), labels=c("No political interest", "Low", "Medium", "High political interest"))
supersom$polinterest.num <- as.numeric(supersom$polinterest)   # Numeric 1-4 political interest.

# Public service.
supersom$svt1 <- supersom$jd20a             # SVT1
supersom$svt2 <- supersom$jd20b             # SVT2 (1992-2014)
supersom$svt1svt2 <- supersom$jd20c         # SVT1/SVT2 (2006-2013)
supersom$rapport <- supersom$jh10d          # SVT1 Rapport
supersom$aktuellt <- supersom$jh10c         # SVT2 Aktuellt
supersom$aktuelltrapport <- supersom$jh10e  # Aktuellt/Rapport
supersom$ekot <- supersom$jh10b             # SR Ekot

# Trust SVT.
supersom$trust.svt <- supersom$ka502a %>% recode("1"="3", "2"="3", "3"="2", "4"="1", "5"="1")
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
supersom$trust.svt <- factor(supersom$trust.svt, levels=c(3, 2, 1), labels=c("High trust", "Neither low nor high", "Low trust"))
supersom$trust.sr <- supersom$ka502e %>% recode("1"="3", "2"="3", "3"="2", "4"="1", "5"="1")
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
supersom$trust.sr <- factor(supersom$trust.sr, levels=c(3, 2, 1), labels=c("High trust", "Neither low nor high", "Low trust"))

# Social networking sites.
supersom$sns <- supersom$jb110p          # Social media, e.g. Facebook, Twitter (2009-2014)

# Recode into binary.
supersom$svt1.dich     <- dummy(supersom$svt1, one=c(2, 3, 4, 5), zero=c(6, 7), labels=c("Daily/weekly", "Never/seldom"))
supersom$svt2.dich     <- dummy(supersom$svt2, one=c(2, 3, 4, 5), zero=c(6, 7), labels=c("Daily/weekly", "Never/seldom"))
supersom$rapport.dich  <- dummy(supersom$rapport, one=c(1, 2, 3, 4), zero=c(5, 6), labels=c("Daily/weekly", "Never/seldom"))
supersom$aktuellt.dich <- dummy(supersom$aktuellt, one=c(1, 2, 3, 4), zero=c(5, 6), labels=c("Daily/weekly", "Never/seldom"))
supersom$ekot.dich     <- dummy(supersom$ekot, one=c(1, 2, 3, 4), zero=c(5, 6), labels=c("Daily/weekly", "Never/seldom"))
supersom$sns.dich      <- dummy(supersom$sns, one=c(7, 6, 5), zero=c(4, 3, 2, 1), labels=c("Daily/weekly", "Never/seldom"))

# Combine Aktuell/RApport into single variable.
supersom$aktuelltrapport.dich[supersom$year %in% c(1984:2004)] <- ifelse(supersom$aktuellt[supersom$year %in% c(1984:2004)] <= 5 | supersom$rapport[supersom$year %in% c(1984:2004)] <= 5, 1, 0)
supersom$aktuelltrapport.dich[supersom$year %in% c(2005:2015)] <- ifelse(supersom$aktuelltrapport[supersom$year %in% c(2005:2015)] <= 5, 1, 0)
supersom$aktuelltrapport.dich <- factor(supersom$aktuelltrapport.dich, levels=c(1, 0), labels=c("Daily/weekly", "Never/seldom"))

# Very inclusive dichotomous public service index: Using any of Rapport/Aktuellt/Ekot at least 1 time per week or not.
supersom$psindex <- supersom %>% with(ifelse(as.numeric(aktuelltrapport.dich) == 1 | as.numeric(ekot.dich) == 1, 1, 0))
supersom$psindex <- factor(supersom$psindex, levels=c(1, 0), labels=c("PS news daily/weekly", "PS news never/seldom"))

# Additive public service index: Using any of Rapport/Aktuellt/Ekot at least 1 time per week.
supersom$psindex.num <- as.numeric(supersom$aktuellt + supersom$rapport + supersom$ekot)
supersom$psindex.num <- as.numeric(recode(supersom$psindex.num, "18"="1",
                                            "17"="1",
                                            "16"="2",
                                            "15"="3",
                                            "14"="4",
                                            "13"="5",
                                            "12"="6",
                                            "11"="7",
                                            "10"="8",
                                             "9"="9",
                                             "8"="10",
                                             "7"="11",
                                             "6"="12",
                                             "5"="13",
                                             "4"="14",
                                             "3"="15",
                                             "2"="16",
                                             "1"="17"))

#supersom$psindex.num[supersom$year %in% c(2005:2015)] <- (supersom$aktuelltrapport[supersom$year %in% c(2005:2015)] + supersom$ekot[supersom$year %in% c(2005:2015)])

# Lef/right block.
supersom$partyblock[supersom$cb10 %in% c(1, 2, 7)] <- 1     # Left: S+V+MP
supersom$partyblock[supersom$cb10 %in% c(3, 4, 5, 6)] <- 2  # Right: C+L+M+KD
supersom$partyblock[supersom$partyblock > 2] <- NA
supersom$partyblock <- factor(supersom$partyblock, levels=1:2, labels=c("Left", "Right"), ordered=FALSE)

# Party.
supersom$party <- factor(supersom$cb10, levels=c(1:7, 10:13, 30), labels=c("Vänsterpartiet", "Socialdemokraterna", "Centerpartiet", "Folkpartiet", "Moderaterna", "Kristdemokraterna", "Miljöpartiet", "Sverigedemokraterna", "Feministiskt initiativ", "Piratpartiet", "Ny demokrati", "Övriga"), ordered=FALSE)

# Ideological extremism (center = 0, toward left/right = 2)
supersom$polextreme <- supersom$ideology %>% recode("1"="2", "2"="1", "0"="2", "4"="1", "5"="2") %>% as.numeric()
## Warning: Unreplaced values treated as NA as .x is not compatible. Please
## specify replacements exhaustively or supply .default
# Political leaning: left/center/right.
supersom$leaning <- supersom$ideology %>% recode("1"="1", "2"="1", "3"="2", "4"="3", "5"="3")
supersom$leaning <- factor(supersom$leaning, levels=c(1,2,3), labels=c("Left", "Center", "Right"), ordered=FALSE)

# Convert year to date yyyy-mm-dd.
supersom$date <- as.Date(paste(supersom$year, "-01-01", sep=""))

Swedish Television

SVT1

title <- attr(supersom$svt1, "label")

# Get PS use and plot.
supersom %>%
  select(date, svt1.dich) %>%
  na.exclude() %>%
  group_by(date, svt1.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = (n / sum(n)) * 100) %>%
  ggplot(aes(date, percent, color=factor(svt1.dich))) +
    geom_line(size=1.2) +
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom") +
    labs(title=paste(title), x="Year", y="Percent")

SVT1 & leaning

title <- attr(supersom$svt1, "label")

supersom %>%
  select(date, svt1.dich, leaning) %>%
  na.exclude() %>%
  group_by(leaning, date, svt1.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(svt1.dich))) +
    geom_line(size=1.2) + 
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Percent") +
    facet_grid(~ leaning)

SVT1 & political interest

title <- attr(supersom$svt1, "label")

# Get PS use and plot.
supersom %>%
  select(date, svt1.dich, polinterest) %>%
  na.exclude() %>%
  group_by(polinterest, date, svt1.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(svt1.dich))) +
    geom_line(size=1.2) + 
    #geom_smooth(method="lm") +
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Percent") +
    facet_grid(~ polinterest)

SVT1 & extremity

# Are public service viewers more extreme in their views?
supersom %>%
  select(date, svt1.dich, polextreme) %>%
  na.exclude() %>%
  group_by(svt1.dich, date) %>%
  summarize(meanextremism = mean(polextreme, na.rm=TRUE)) %>%
  ggplot(aes(date, meanextremism, color=svt1.dich)) +
    geom_line(alpha=0.5) +
    geom_smooth(method="loess") +
    scale_y_continuous(labels=scales::comma) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "none", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Ideological extremism") +
    facet_grid(~ svt1.dich)

SVT2 & leaning

title <- attr(supersom$svt2, "label")

# Get PS use and plot.
supersom %>%
  select(date, svt2.dich, leaning) %>%
  na.exclude() %>%
  group_by(leaning, date, svt2.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(svt2.dich))) +
    geom_line(size=1.2) + 
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Percent") +
    facet_grid(~ leaning)

SVT2 & political interest

title <- attr(supersom$svt2, "label")

# Get PS use and plot.
supersom %>%
  select(date, svt2.dich, polinterest) %>%
  na.exclude() %>%
  group_by(polinterest, date, svt2.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(svt2.dich))) +
  geom_line(size=1.2) + 
  #geom_smooth(method="lm") +
  scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
  scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
  scale_x_date(date_label="%Y", date_breaks="2 year") + 
  theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
  labs(title=paste(title),
       x="Year",
       y="Percent") +
  facet_grid(~ polinterest)

Swedish Television news programmes Rapport and Aktuellt in SVT1 and SVT2, respectively.

Rapport & leaning

title <- attr(supersom$rapport, "label")

supersom %>%
  select(date, rapport.dich, leaning) %>%
  na.exclude() %>%
  group_by(leaning, date, rapport.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(rapport.dich))) +
    geom_line(size=1.2) + 
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Percent") +
    facet_grid(~ leaning)

Rapport & political interest

title <- attr(supersom$rapport, "label")

# Get PS use and plot.
supersom %>%
  select(date, rapport.dich, polinterest) %>%
  na.exclude() %>%
  group_by(polinterest, date, rapport.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(rapport.dich))) +
    geom_line(size=1.2) + 
    #geom_smooth(method="lm") +
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Percent") +
    facet_grid(~ polinterest)

Aktuellt & leaning

title <- attr(supersom$aktuellt, "label")

supersom %>%
  select(date, aktuellt.dich, leaning) %>%
  na.exclude() %>%
  group_by(leaning, date, aktuellt.dich) %>%
  summarize(n = n()) %>%
  mutate(percent = n / sum(n) * 100) %>%
  ggplot(aes(date, percent, color=factor(aktuellt.dich))) +
    geom_line(size=1.2) + 
    scale_color_manual(values = c("#000000", "#CCCCCC"), name=NULL) +
    scale_y_continuous(labels=scales::comma, limit=c(0, 100)) +
    scale_x_date(date_label="%Y", date_breaks="2 year") + 
    theme(legend.position = "bottom", axis.text.x = element_text(angle=90)) +
    labs(title=paste(title),
         x="Year",
         y="Percent") +
    facet_grid(~ leaning)