library(tidyverse)
Посмотрим на названия столбцов:
colnames(chickwts)
## [1] "weight" "feed"
Воспроизведем график из задания 1:
ggplot(data = chickwts, aes(x = feed, y = weight, fill = feed)) +
geom_boxplot() +
labs(title = "Weights of chicken by feed type",
x = "Type of feed", y = "Chicken weight") +
scale_fill_discrete(name = "Type of feed")
x
: типы корма;y
: вес цыплят;fill
по типу корма;Посмотрим на названия столбцов:
colnames(iris)
## [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
Воспроизведем график из задания 2:
ggplot(data = iris, aes(x = Sepal.Length, fill = Species)) +
geom_density() + facet_wrap(~Species) +
scale_fill_manual(values = c("red", "orange", "yellow"))
x
идет Sepal.Length
, строим график плотности;fill
зависит от сорта ириса;scale_fill_manual()
.Посмотрим на названия столбцов:
colnames(iris)
## [1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"
Воспроизведем график из задания 3:
ggplot(data = iris, aes(x = Sepal.Length, y = Petal.Length,
color = Species)) +
geom_point() + geom_smooth(method = lm)
## `geom_smooth()` using formula 'y ~ x'
x
и y
;geom_smooth()
и выставляем метод lm
(linear model).