r - 数据集使用和变量选择
问题描述
我上传了数据集。但是我如何展示那些在欧洲死去的人。
df <- read.csv ('https://raw.githubusercontent.com/ulklc/covid19-timeseries/master/countryReport/raw/rawReport.csv')
europe <-- df[df$region =="Europe"]
df$death [europe]
解决方案
我们只能过滤欧洲国家并按国家计算死亡人数。
这可以在基础 R 中完成:
df1 <- aggregate(death~countryName, subset(df, region =="Europe"), sum)
dplyr
library(dplyr)
df1 <- df %>%
filter(region == 'Europe') %>%
group_by(countryName) %>%
summarise(total_death = sum(death))
并且在data.table
df1 <- setDT(df)[region == 'Europe', (total_death = sum(death)), countryName]
推荐阅读
- javascript - face-api.js:实时网络摄像头识别问题
- java - 在 Jhipster Java Back 服务上更新查询后请求返回错误值
- github - 如何关闭 GitHub Codespaces?
- c++ - 尽管使用了 long long int,但由于溢出而导致的负结果
- multidimensional-array - 如何通过用户空间中的 read() 函数从内核设备驱动程序获取二维数组
- angular-material - Angular 11 Mat Select 更改选项高度打破了位置
- python - 仅提取边界框中的文本并将它们发送到 http 服务器
- python - 将数据帧合并为一个主数据帧
- java - 应用程序在后台时如何获取应用程序上下文?(Flutter 插件 android 代码具体)
- go - VS Code Go:在实现接口的方法旁边有一个指示器