简体   繁体   中英

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.

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. This is probably causing the issues within your group_by statement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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