简体   繁体   English

group_by 并总结 tidyverse package 在 r 中的用法

[英]group_by and summarize usage in tidyverse package in r

I am analyzing the COVID-19 data in r and I want to get the aggregate result of total case in different continent.我正在分析 r 中的 COVID-19 数据,我想获得不同大陆总病例的汇总结果。

total_cases_continent <- covid_data %>% 
select(continent, new_cases) %>% 
group_by(continent) %>% 
summarize(total_cases = sum(new_cases))

I get this result below, instead of present total cases in different continent, this only shows total cases in different continent in one row我在下面得到这个结果,而不是显示不同大陆的总病例数,这只显示一行中不同大陆的总病例数

It looks like there might be some issues with the values of your variable "continent".看起来您的变量“大陆”的值可能存在一些问题。 I would recommend checking the class of the variable, as well as making sure all of the values are what you expected them to be.我建议检查变量的 class,并确保所有值都符合您的预期。 This is probably causing the issues within your group_by statement.这可能会导致您的 group_by 语句中出现问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM