Поздняков Иван
Выпускник МГУ (2014) и Вышки (2016)
Работаю дата-аналитиком
Cтарший преподаватель Школы Лингвистики НИУ ВШЭ
Cognitive neuroscience, Digital Literary Studies
Для тех, кто без опыта программирования: R с нуля
Для тех, кто умеет в MATLAB, python: R-way
Для тех, кто уже знает R: продвинутые фишки R
И все это в едином потоке безумия
Много практики (в т.ч. на данных)
Задания разного уровня
Да, будет тяжело
Бог терпел и нам велел
Создание функций
Функции семейства apply()
Работа с пакетами
Основы tidyverse
Текстовые:
.csv = comma separated values
.tsv = tab separated values
.txt, .dat и так далее
Бинарные:
apply()
Студент | До курса по R | После курса по R |
---|---|---|
Маша | 70 | 63 |
Рома | 80 | 74 |
Антонина | 86 | 71 |
Студент | Время измерения | Вес (кг) |
---|---|---|
Маша | До курса по R | 70 |
Рома | До курса по R | 80 |
Антонина | До курса по R | 86 |
Маша | После курса по R | 63 |
Рома | После курса по R | 74 |
Антонина | После курса по R | 71 |
Слои (Layers):
Data
Mapping (aes)
Statistical transformation (stat)
Geometric object (geom)
Position adjustment (position)
На одном графике можно соединять несколько слоев!
Кроме слоев, у графика есть:
scale
Coordinate system (coord)
Faceting (facet)
theme
“…In brief, the grammar tells us that a statistical graphic is a mapping from data to aesthetic attributes (colour, shape, size) of geometric objects (points, lines, bars). The plot may also contain statistical transformations of the data and is drawn on a specific coordinate system. Facetting can be used to generate the same plot for different subsets of the dataset…” (Hadley Wickham, “ggplot2: Elegant Graphics for Data Analysis”, 2016)
library(tidyverse)
got <- read_csv("data/character-deaths.csv")
ggplot(data = got)
ggplot(data = got) +
geom_bar(aes(x = "", fill = as.factor(Gender)))
ggplot(data = got) +
geom_bar(aes(x = "", fill = as.factor(Gender)))+
coord_polar(theta = "y")
ggplot(data = got) +
geom_bar(aes(x = "", fill = as.factor(Gender)))+
coord_polar(theta = "y")+
theme_void()
Мета-анализ связи количества лет обучения и интеллект: “How Much Does Education Improve Intelligence? A Meta-Analysis” (Ritchie, Tucker-Drob, 2018)
Данные и скрипт находятся в открытом доступе: https://osf.io/r8a24/
cowplot
- for publications
Dynamic visualization
Using d3.js
library(plotly)
data(diamonds)
diamonds <- diamonds[sample(nrow(diamonds), 1000),]
gg <- ggplot(data = diamonds)+
geom_point(aes(x = carat, y = price, colour = price), alpha = 0.1)
ggplotly(gg)
plot_ly(diamonds, x = ~carat, y = ~price, color = ~carat, size = ~carat)
http://gallery.htmlwidgets.org/
leaflet
listviewer
wordcloud2
networkD3