'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



Solution 1:[1]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gabrielle