{r penguin_plot, echo=FALSE, warning=FALSE, message=FALSE, fig.width=10, fig.height=7} # Очистка данных от пропусков penguins_clean <- penguins %>% drop_na()

Создание визуализации

ggplot(data = penguins_clean, mapping = aes(x = bill_length_mm, y = bill_depth_mm, color = species, shape = species)) + # 1. Слой: Точки с прозрачностью для наглядности наложений geom_point(size = 3, alpha = 0.7) + # 2. Дополнительное расширение: Выделение «облаков» данных для каждого вида geom_mark_ellipse(aes(fill = species, label = species), alpha = 0.1, show.legend = FALSE) + # 3. Слой: Линии линейной регрессии для каждого вида отдельно geom_smooth(method = “lm”, formula = y ~ x, se = FALSE, linewidth = 1) + # Оформление меток labs( title = “Геометрия клюва пингвинов Архипелага Палмера”, subtitle = “Сравнение длины и глубины клюва (Адели, Чинстрап, Генту)”, x = “Длина клюва (мм)”, y = “Глубина клюва (мм)”, color = “Вид пингвина”, shape = “Вид пингвина” ) + # 4. Оформление темы и цветов (стиль WSJ или Tableau) theme_fivethirtyeight() + scale_color_tableau() + scale_fill_tableau() + theme( axis.title = element_text(face = “bold”), plot.title = element_text(size = 16, hjust = 0), legend.position = “bottom” )

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.