group_by does not see a column

Hi all,
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:

# 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)) %>%

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

If you wirte data <- df4 %>% group_by(Country) is the same error occur? I meant to ignore the rest of your code and check this part. If it is maybe try use group_by(df4[,2]). This should directly refer to the column that it supposedly does not see

Is dplyr::group_by overloaded by another package? Type > group_by at the command line to see.

I wrote as you suggested first

> View(data)```
and then 

```> data %>% summarise(Totall = sum(Total))```

And it looks like it is working. For some reason the pipes %>% seem to obstruct the process.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.