library(ggplot2)
library(readxl)
library(dplyr)
## 
## Присоединяю пакет: 'dplyr'
## Следующие объекты скрыты от 'package:stats':
## 
##     filter, lag
## Следующие объекты скрыты от 'package:base':
## 
##     intersect, setdiff, setequal, union
TeachingRatings <- read_excel("TeachingRatings.xls")

str(TeachingRatings)
## tibble [463 × 8] (S3: tbl_df/tbl/data.frame)
##  $ minority   : num [1:463] 1 0 0 0 0 0 0 0 0 0 ...
##  $ age        : num [1:463] 36 59 51 40 31 62 33 51 33 47 ...
##  $ female     : num [1:463] 1 0 0 1 1 0 1 1 1 0 ...
##  $ onecredit  : num [1:463] 0 0 0 0 0 0 0 0 0 0 ...
##  $ beauty     : num [1:463] 0.29 -0.738 -0.572 -0.678 1.51 ...
##  $ course_eval: num [1:463] 4.3 4.5 3.7 4.3 4.4 4.2 4 3.4 4.5 3.9 ...
##  $ intro      : num [1:463] 0 0 0 0 0 0 0 0 0 0 ...
##  $ nnenglish  : num [1:463] 0 0 0 0 0 0 0 0 0 0 ...
#ошибка 1
ggplot(data = TeachingRatings, aes(x = minority)) + geom_bar(fill = "lightblue") + theme_minimal()

ggplot(data = TeachingRatings, aes(x = as.character(minority))) + geom_bar(fill = "lightblue") + theme_minimal()

#ошибка 2 
ggplot(data = TeachingRatings, aes(x = as.character(minority))) + geom_bar(color = "darkblue") + theme_minimal()

ggplot(data = TeachingRatings, aes(x = as.character(minority))) + geom_bar(fill = "darkblue") + theme_minimal()

#ошибка 3
ggplot(data = TeachingRatings, aes(x = as.character(minority), y = age)) + geom_col(fill = "purple") + theme_minimal()

TeachingRatings1 <- TeachingRatings %>% group_by(minority) %>% summarise(age = mean(age))
ggplot(data = TeachingRatings1, aes(x = as.character(minority), y = age)) + geom_col(fill = "purple") + theme_minimal()