I'm sorry, I will be writing them bellow.
The dataset I'm using is:
unvoting <- read.csv("https://raw.githubusercontent.com/umbertomig/intro-prob-stat-FGV/master/datasets/unvoting.csv")
Then, I have to create a vector with the former USSR countries:
formerussrcountries <- c("Estonia","Latvia","Lithuania","Belarus","Moldova","Ukraine","Armenia","Azerbaijan","Georgia","Kazakhstan","Kyrgyzstan","Tajikistan","Turkmenistan","Uzbekistan","Russia")
After that, I have to examine how the median ideal points of Soviet/post-Soviet countries and all other countries have varied over all the years in the data. For that, I have to plot these median ideal points by year.
These are the codes I'm writing, but when I run the plot, it says that my x and y leghts differ.
formerussrcountries2 <- filter (unvoting, formerussrcountries == 1)
restofthecountries <- filter (unvoting, formerussrcountries == 0)
tapply(formerussrcountries$idealpoint, formerussrcountries$Year, median)
tapply(restofthecountries$idealpoint, restofthecountries$Year, median)
plot(formerussrcountries2$Year,
tapply(formerussrcountries2$Year, formerussrcountries2$idealpoint, median),
xlab = "Year",
ylab = "ideal points")
lines(formerussrcountries2$Year,
tapply(restofthecountries$idealpoint, restofthecountries$Year, median))