I am having problem with grouping and suming columns in my data frame.
I have a data frame which contains more than 20k rows and look like this:
head(df4) # A tibble: 6 x 5 Region Country Year Total iso3c <chr> <chr> <chr> <dbl> <chr> 1 Africa West Western Africa 2020 20250000 NA 2 Africa East United Republic of Tanzania 2020 117000000 TZA 3 Africa West Republic of Cote d'Ivoire 2020 250000000 CIV 4 Africa East Republic of Malawi 2020 100000000 MWI 5 Middle East and North Africa Republic of Tunisia 2020 2000000 TUN 6 Africa East Republic of Mozambique 2020 100000000 MOZ
Now, I would like to group it by country and sum the Total column as a new df
I wrote the following line:
data <- df4 %>% + group_by(Country) %>% + summarise(Totall = sum(Total)) %>% + as.data.frame()
However, I get the following error: Error in group_by(Country) : object 'Country' not found. I know that the column name is spelled properly and I have no idea what could be the cause of the error.
Thanks in advance for any hints