i want to count the amount of categories of goods from different countries, like china have 2 kinds of goods
I type the function below, help me correct them and explain it to me, thinks a lot.
dataframe %>%
group_by (country_name) %>%
summarise(amount of goods = count(country_name))
R notes to me that an error occurred in group 1: country name = "CHINA"
Does means that I have used group_by() and do not use count() in group_by() again?
As a start, place every string in quotes, be sure you have the same number of consultants_name as goods, load library(dplyr), don't use country_name if you are using consultants_name, and don't define amount of goods with spaces but rather as amount_of_goods
In addition to what fcas80 says, you may be using the wrong function: within summarise(), you want to use n() to count the number of rows in the group; otherwise count() is a shortcut where:
df %>% count(a, b) is roughly equivalent to df %>% group_by(a, b) %>% summarise(n = n())