【问题标题】:How can I plot the evolution of two variables over a time range? Add the yearly median ideal point of the two varibles如何绘制两个变量在时间范围内的演变?添加两个变量的年度中值理想点
【发布时间】:2020-05-13 01:40:59
【问题描述】:

使用同意美国或俄罗斯的选票比例作为衡量国家偏好的一个问题是,两国的意识形态立场以及因此的投票模式本身可能会随着时间而改变。这使得很难知道哪些国家的意识形态立场发生了变化。通过绘制两国理想点随时间的演变来研究这个问题。添加所有国家的年度中值理想点。此分析的结果如何修改(或不修改)您对先前分析的解释?

https://raw.githubusercontent.com/umbertomig/intro-prob-stat-FGV/master/datasets/unvoting.csv”中的可用数据

这是我目前能够做到的:

unvotes<-read.csv("https://raw.githubusercontent.com/umbertomig/intro-prob-stat-FGV/master/datasets/unvoting.csv")
  data<- filter(unvotes, Year==2012)
    data$CountryAbb<-NULL

【问题讨论】:

  • 嗨,Gabriela,我最近回答了similar question。我想知道你们两个是不是同一个班。此外,您的老师显然正在将整个互联网上的数据集上传到他的 GitHub,而没有署名。

标签: r


【解决方案1】:
UNvotes <- read.csv("https://raw.githubusercontent.com/umbertomig/intro-prob-stat-FGV/master/datasets/unvoting.csv")

str(UNvotes)

library(dplyr)
library(ggplot2)

data <- filter(UNvotes, CountryAbb %in% c('RUS','USA'))

Median <- group_by(UNvotes, Year) %>%
  summarise(m=median(idealpoint))

ggplot(data, aes(x=Year, y=idealpoint, col=CountryName)) +
  geom_line() +
  geom_line(data=Median, aes(y=m), col="blue", lty=2) +
  labs(caption = "Comparison of idealogical positions for USA and Russia.
                  \nBlue dotted line indicates yearly median of all countries") +
  theme_minimal() +
  theme(legend.title=element_blank(), legend.position = "bottom", 
        plot.caption = element_text(hjust = 0, face="italic"))

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-07
    • 2023-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    相关资源
    最近更新 更多