load manifestoR and read api key taken from manifesto profile web page

setwd("~/Downloads")
mp_setapikey("manifesto_apikey.txt")
alldata <- mp_maindataset()

parse data

turkey <- subset(alldata, countryname== "Turkey")

check right-left measurement

turkey$rile2 <- rile(turkey) cbind(turkey$rile2, turkey$rile) cor(turkey$rile, turkey$rile2) #there are small differences but check is okay#

plotting left-right scores with % of votes across years (color)

attach(turkey)
turkey$year <- substr(turkey$edate, 0, 4)
plot <- ggplot(turkey,aes(rile2,pervote,color=factor(year), label=(partyabbrev),size=5) )
left_right_plot <- plot + geom_text(check_overlap = TRUE, size=3) + labs(x="Left-Right", y="Vote", colour="Year") + theme(legend.key.size= unit(0.2, "cm")) + guides(col = guide_legend(ncol = 2))

calculating manifesto issue diversity for each party

turkey$issues <- issue_attention_diversity(turkey, method="herfindahl", prefix=("per"), aggregate_categories = list(c(101, 102), c(104, 105), c(107, 109), c(108, 110), c(203, 204), c(301, 302), c(406, 407), c(409, 414), c(504, 505), c(506,507), c(601, 602), c(603, 604), c(607, 608), c(701, 702))) attach(turkey)

correlation matrix

correl <- cbind(pervote, rile, issues) cor(correl)

linear regression of issue diversity and left-right on vote

fit <- lm(pervote ~ rile + issues, data=turkey) summary(fit) fit_interact <- lm(pervote ~ rile + issues + rile*issues, data=turkey) summary(fit_interact) anova(fit, fit_interact,test="Chisq")

plotting average issue diversity across elections

issues_year=aggregate(issues~edate, FUN=function(x) c(mean=mean(x))) issue_plot <- ggplot(data=issues_year, aes(x=edate, y=issues, group=1)) + geom_point(size=1) +xlab("Election")+ylab("Issues")+ggtitle("Issue Diversity") + geom_smooth(fill="red", colour="red", size=1)

{r pressure, echo=FALSE}
issue_plot