При отображении «данных» group_by
не требуется, если мы используем count
library(dplyr)
data %>%
dplyr::count(yearmo, eco)
# A tibble: 3 x 3
# yearmo eco n
# <int> <chr> <int>
#1 200301 negative 13
#2 200301 neutral 5
#3 200301 positive 2
data
data <- structure(list(yearmo = c(200301L, 200301L, 200301L, 200301L,
200301L, 200301L, 200301L, 200301L, 200301L, 200301L, 200301L,
200301L, 200301L, 200301L, 200301L, 200301L, 200301L, 200301L,
200301L, 200301L), sex = c("Male", "Female", "Female", "Male",
"Male", "Male", "Male", "Male", "Female", "Female", "Female",
"Female", "Male", "Female", "Male", "Male", "Female", "Male",
"Female", "Female"), eco = c("neutral", "negative", "negative",
"neutral", "negative", "negative", "negative", "negative", "negative",
"negative", "negative", "negative", "negative", "positive", "negative",
"neutral", "neutral", "neutral", "negative", "positive"), ue = c("negative",
"negative", "negative", "neutral", "negative", "negative", "negative",
"negative", "negative", "negative", "negative", "neutral", "negative",
"neutral", "negative", "negative", "negative", "negative", "negative",
"negative"), fs12ago = c("negative", "negative", "neutral", "neutral",
"negative", "neutral", "neutral", "positive", "negative", "positive",
"negative", "negative", "neutral", "neutral", "neutral", "negative",
"negative", "neutral", "negative", "neutral"), fs12ahead = c("neutral",
"neutral", "neutral", "neutral", "positive", "neutral", "neutral",
"neutral", "neutral", "negative", "negative", "neutral", "neutral",
"neutral", "neutral", "neutral", "neutral", "neutral", "negative",
"neutral"), purchases = c("neutral", "neutral", "positive", "neutral",
"negative", "positive", "neutral", "negative", "positive", "neutral",
"negative", "negative", "negative", "positive", "positive", "neutral",
"neutral", "positive", "positive", "positive")),
class = "data.frame", row.names = c(NA,
-20L))