我正在创建一个图表,显示不同国家(1970-2010年)在某些年份之间的预期寿命的增长以及医疗保健的费用,但是我无法找到一种方法来获得指定年份之间的数据。 另外,这里是查看数据集的链接(如果有帮助的话):https://ourworldindata.org/grapher/life-expectancy-vs-health-expenditure
data <- read.csv("file:///C:/Users/Gavyn Henderson/Downloads/life-expectancy-vs-health-expenditure.csv")
names(data) <- c("Country","CountryABV","Year","LifeExpextancy","Expenditure","Population")
data$Expenditure <- as.numeric(levels(data$Expenditure))[data$Expenditure]
sub1 <- subset(data, CountryABV == "USA"|CountryABV == "GBR"|CountryABV == "DEU"|CountryABV == "FRA"|
CountryABV == "JPN"|CountryABV == "AUS"|CountryABV == "CHE"|CountryABV == "CAN")
sub2 <- subset(data, Year %in% 1970:2010)
gg <- ggplot(sub1) + aes(Expenditure, LifeExpextancy,frame = sub2, color = Country) +
geom_point(aes(size = Population)) + xlab("Life Expectance") +
ylab("Health Expenditure") +
ggtitle("Life Expectance vs. Health Expenditure") +
ylim(65,85) +
xlim(0,8000)
ggplotly(gg)