分析折线图中的最高数据

问题描述 投票:0回答:1
 df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19- 
  timeseries/master/countryReport/raw/rawReport.csv',
            stringsAsFactors = FALSE)
  df1 <- aggregate(death ~ countryName, subset(df), sum)

我创建了具有死亡人数的数据集。

以线图绘制死亡人数最多的五个国家的死亡人数。

r
1个回答
0
投票
library(ggplot2)
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv', stringsAsFactors = FALSE)
df1 <- aggregate(death ~ countryName, subset(df), sum)
top_10_coutries <- df1[order(df1$death,decreasing = T),][1:10,]$countryName

to_plot = df[df$countryName %in% top_10_coutries,]
ggplot(data=to_plot, aes(x=day, y=death, group=countryName)) +
  geom_line(aes(color=countryName))+
  geom_point(aes(color=countryName))+ theme(axis.title.x=element_blank(),
                                          axis.text.x=element_blank(),
                                          axis.ticks.x=element_blank())
© www.soinside.com 2019 - 2024. All rights reserved.