#Источник: https://t.me/rstudioprogr
library(ggplot2)
library(ggdogs)
## ~~ Package ggdogs
## Visit https://r-charts.com/ for R dataviz tutorials :) ~~
library(gridExtra)

data(mtcars)

str(mtcars)
## 'data.frame':    32 obs. of  11 variables:
##  $ mpg : num  21 21 22.8 21.4 18.7 18.1 14.3 24.4 22.8 19.2 ...
##  $ cyl : num  6 6 4 6 8 6 8 4 4 6 ...
##  $ disp: num  160 160 108 258 360 ...
##  $ hp  : num  110 110 93 110 175 105 245 62 95 123 ...
##  $ drat: num  3.9 3.9 3.85 3.08 3.15 2.76 3.21 3.69 3.92 3.92 ...
##  $ wt  : num  2.62 2.88 2.32 3.21 3.44 ...
##  $ qsec: num  16.5 17 18.6 19.4 17 ...
##  $ vs  : num  0 0 1 1 0 1 0 1 1 1 ...
##  $ am  : num  1 1 1 0 0 0 0 0 0 0 ...
##  $ gear: num  4 4 4 3 3 3 3 4 4 4 ...
##  $ carb: num  4 4 1 1 2 1 4 2 2 4 ...
a1 <- ggplot(mtcars, aes(disp, hp)) + geom_dog(size = 4) + theme_bw() + ggtitle("Пес по умолчанию")
#создадим новую таблицу, чтобы задать пса
#32 - количество наблюдений в выборке
dogs <- data.frame(disp = mtcars$disp, hp = mtcars$hp, dog = c(rep("pug", 32))) #тут достаточно поменять имя собаки
a2 <- ggplot(dogs, aes(disp, y = hp, dog = dog)) + geom_dog(size = 4) + theme_bw() + ggtitle("Пес - pug")

dogs1 <- data.frame(disp = mtcars$disp, hp = mtcars$hp, dog = c(rep("gabe", 32)))
a3 <- ggplot(dogs1, aes(disp, y = hp, dog = dog)) + geom_dog(size = 4) + theme_bw() + ggtitle("Пес - gabe")

dogs2 <- data.frame(disp = mtcars$disp, hp = mtcars$hp, dog = c(rep("husky_2", 32)))
a4 <- ggplot(dogs2, aes(disp, y = hp, dog = dog)) + geom_dog(size = 4) + theme_bw() + ggtitle("Пес - husky_2")

dogs3 <- data.frame(disp = mtcars$disp, hp = mtcars$hp, dog = c(rep("glasses", 32)))
a5 <- ggplot(dogs3, aes(disp, y = hp, dog = dog)) + geom_dog(size = 4) + theme_bw() + ggtitle("Пес - glasses")

dogs4 <- data.frame(disp = mtcars$disp, hp = mtcars$hp, dog = c(rep("thisisfine", 32)))
a6 <- ggplot(dogs4, aes(disp, y = hp, dog = dog)) + geom_dog(size = 4) + theme_bw() + ggtitle("Пес - thisisfine")

grid.arrange(a1, a2, a3, a4, a5, a6, ncol = 3)