r - 努力过滤R中的数据
问题描述
这是我正在使用的数据:
https://www.dropbox.com/s/dl/chmzqmus6bfoaim/climate_clean.csv
average_temperature_fahrenheit
我添加了一个通过这样做调用的变量
climate = mutate(climate, average_temperature_fahrenheit = 9/5*average_temperature_celsius+32)
现在我想知道 1970 年至 1980 年间欧洲和北美 6 月、7 月和 8 月的华氏温度最高,所以我想我需要climate
通过这样做来过滤我的数据框
climate %>% filter(continent == c("Europe","North America") & month == c("Jun","Jul","Aug") & year[1970:1980])
但显然我没有成功,因为它只显示了八月
filter
请你能告诉我我在功能部分搞砸的地方吗
解决方案
你可以和
library(data.table)
climate <-fread("~/downloads/climate_clean.csv")
climate %>%
mutate(average_temperature_fahrenheit = 9/5*average_temperature_celsius+32) %>%
filter(year %in% 1970:1980, month %in% c("Jun", "Jul", "Aug")) %>%
group_by(continent) %>%
summarise(MaxF = max(average_temperature_fahrenheit))
# A tibble: 6 x 2
continent MaxF
<chr> <dbl>
1 Africa 93.6
2 Asia 98.6
3 Europe 83.9
4 North America 83.0
5 Oceania 83.7
6 South America 80.2
推荐阅读
- c - C 编译器接受的可疑 case 语句语法
- assert - 为什么没有推断出这个愚蠢的后置条件?
- d3.js - D3 Transition Path Left And Shift Up/Down Simultaneously
- android - 从 db 获取的对象框显示过时信息
- python - 指令在呈现的文档中显示为文字文本
- google-cloud-platform - Terraform - 使用多个存储类部署 GCP 存储桶?
- vba - VBA Word更改形状中的文本颜色
- google-cloud-platform - 如何使用 Python 创建/管理 GCP API 密钥
- android - expo-notifications scheduleNotification 在设备中未按预期工作
- android - Firebase Android 排行榜系统