Π Π±ΠΎΠ»ΡΡΠΈΠ½ΡΡΠ²Π΅ ΡΠ»ΡΡΠ°Π΅Π² ΠΏΡΠΈ ΡΠ°Π±ΠΎΡΠ΅ Ρ ΠΎΡΠ²Π΅ΡΠΎΠΌ ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΡΠΌ ΠΎΡ API, ΠΈΠ»ΠΈ Ρ Π»ΡΠ±ΡΠΌΠΈ Π΄ΡΡΠ³ΠΈΠΌΠΈ Π΄Π°Π½Π½ΡΠΌΠΈ ΠΊΠΎΡΠΎΡΡΠ΅ ΠΈΠΌΠ΅ΡΡ ΡΠ»ΠΎΠΆΠ½ΡΡ Π΄ΡΠ΅Π²ΠΎΠ²ΠΈΠ΄Π½ΡΡ ΡΡΡΡΠΊΡΡΡΡ, Π²Ρ ΡΡΠ°Π»ΠΊΠΈΠ²Π°Π΅ΡΠ΅ΡΡ Ρ ΡΠΎΡΠΌΠ°ΡΠ°ΠΌΠΈ JSON ΠΈ XML.
ΠΡΠΈ ΡΠΎΡΠΌΠ°ΡΡ ΠΈΠΌΠ΅ΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΠΏΡΠ΅ΠΈΠΌΡΡΠ΅ΡΡΠ²: ΠΎΠ½ΠΈ Π΄ΠΎΡΡΠ°ΡΠΎΡΠ½ΠΎ ΠΊΠΎΠΌΠΏΠ°ΠΊΡΠ½ΠΎ Ρ ΡΠ°Π½ΡΡ Π΄Π°Π½Π½ΡΠ΅ ΠΈ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΡΡ ΠΈΠ·Π±Π΅ΠΆΠ°ΡΡ ΠΈΠ·Π»ΠΈΡΠ½Π΅Π³ΠΎ Π΄ΡΠ±Π»ΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΠΈ.
ΠΠΈΠ½ΡΡΠΎΠΌ Π΄Π°Π½Π½ΡΡ ΡΠΎΡΠΌΠ°ΡΠΎΠ² ΡΠ²Π»ΡΠ΅ΡΡΡ ΡΠ»ΠΎΠΆΠ½ΠΎΡΡΡ ΠΈΡ ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠΈ ΠΈ Π°Π½Π°Π»ΠΈΠ·Π°. ΠΠ΅ΡΡΡΡΠΊΡΡΡΠΈΡΠΎΠ²Π°Π½Π½ΡΠ΅ Π΄Π°Π½Π½ΡΠ΅ Π½Π΅Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ Π² Π²ΡΡΠΈΡΠ»Π΅Π½ΠΈΡΡ ΠΈ Π½Π΅Π»ΡΠ·Ρ ΡΡΡΠΎΠΈΡΡ Π½Π° ΠΈΡ ΠΎΡΠ½ΠΎΠ²Π΅ Π²ΠΈΠ·ΡΠ°Π»ΠΈΠ·Π°ΡΠΈΡ.
ΠΠ°Π½Π½Π°Ρ ΡΡΠ°ΡΡΡ ΡΠ²Π»ΡΠ΅ΡΡΡ Π»ΠΎΠ³ΠΈΡΠ΅ΡΠΊΠΈΠΌ ΠΏΡΠΎΠ΄ΠΎΠ»ΠΆΠ΅Π½ΠΈΠ΅ΠΌ ΠΏΡΠ±Π»ΠΈΠΊΠ°ΡΠΈΠΈ tidyr
, Π²Ρ
ΠΎΠ΄ΡΡΠ΅Π³ΠΎ Π² ΡΠ΄ΡΠΎ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ tidyverse
, ΠΈ Π΅Π³ΠΎ ΡΡΠ½ΠΊΡΠΈΠΉ ΡΠ΅ΠΌΠ΅ΠΉΡΡΠ²Π° unnest_*()
.
Π‘ΠΎΠ΄Π΅ΡΠΆΠ°Π½ΠΈΠ΅
ΠΡΠ»ΠΈ Π²Ρ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΡΠ΅ΡΠ΅ΡΡ Π°Π½Π°Π»ΠΈΠ·ΠΎΠΌ Π΄Π°Π½Π½ΡΡ
Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ Π²Π°ΠΌ Π±ΡΠ΄ΡΡ ΠΈΠ½ΡΠ΅ΡΠ΅ΡΠ½Ρ ΠΌΠΎΠΈ
ΠΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΠΈ GitHub Π Π΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΈ Github ΠΠ΅ΡΡΠΎΠ½Π°ΠΆΠΈ ΠΠ³ΡΡ ΠΡΠ΅ΡΡΠΎΠ»ΠΎΠ² ΠΠ΅ΠΎΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Google ΠΠΈΡΠΊΠΎΠ³ΡΠ°ΡΠΈΡ Π¨Π°ΡΠ»Ρ ΠΠ΅Π»ΡΡΠ°Π½Π΄ ΠΠ°ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
ΠΠ²Π΅Π΄Π΅Π½ΠΈΠ΅
Rectangling (ΠΏΡΠΈΠΌ. ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄ΡΠΈΠΊΠ°, Π½Π΅ Π½Π°ΡΠ΅Π» Π°Π΄Π΅ΠΊΠ²Π°ΡΠ½ΡΡ
Π²Π°ΡΠΈΠ°Π½ΡΠΎΠ² ΠΏΠ΅ΡΠ΅Π²ΠΎΠ΄Π° ΡΡΠΎΠ³ΠΎ ΡΠ΅ΡΠΌΠΈΠ½Π°, ΠΏΠΎΡΡΠΎΠΌΡ ΠΎΡΡΠ°Π²ΠΈΠΌ Π΅Π³ΠΎ ΠΊΠ°ΠΊ Π΅ΡΡΡ.) β ΡΡΠΎ ΠΏΡΠΎΡΠ΅ΡΡ ΠΏΡΠΈΠ²Π΅Π΄Π΅Π½ΠΈΡ Π½Π΅ ΡΡΡΡΠΊΡΡΡΠΈΡΠΎΠ²Π°Π½Π½ΡΡ
Π΄Π°Π½Π½ΡΡ
Ρ Π²Π»ΠΎΠΆΠ΅Π½Π½ΡΠΌΠΈ ΠΌΠ°ΡΡΠΈΠ²Π°ΠΌΠΈ ΠΊ Π΄Π²ΡΡ
ΠΌΠ΅ΡΠ½ΠΎΠΉ ΡΠ°Π±Π»ΠΈΡΠ΅, ΡΠΎΡΡΠΎΡΡΠ΅ΠΉ ΠΈΠ· ΠΏΡΠΈΠ²ΡΡΠ½ΡΡ
Π½Π°ΠΌ ΡΡΡΠΎΠΊ ΠΈ ΡΡΠΎΠ»Π±ΡΠΎΠ². Π tidyr
Π΅ΡΡΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΡΠ½ΠΊΡΠΈΠΉ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΏΠΎΠΌΠΎΠ³ΡΡ Π²Π°ΠΌ ΡΠ°Π·Π²Π΅ΡΠ½ΡΡΡ Π²Π»ΠΎΠΆΠ΅Π½Π½ΡΠ΅ ΡΡΠΎΠ»Π±ΡΡ-ΡΠΏΠΈΡΠΊΠΈ ΠΈ ΠΏΡΠΈΠ²Π΅ΡΡΠΈ Π΄Π°Π½Π½ΡΠ΅ ΠΊ ΠΏΡΡΠΌΠΎΡΠ³ΠΎΠ»ΡΠ½ΠΎΠΉ, ΡΠ°Π±Π»ΠΈΡΠ½ΠΎΠΉ ΡΠΎΡΠΌΠ΅:
unnest_longer()
Π±Π΅ΡΠ΅Ρ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΡΠΏΠΈΡΠΊΠ°-ΡΡΠΎΠ»Π±ΡΠ° ΠΈ ΡΠΎΠ·Π΄Π°Π΅Ρ Π½ΠΎΠ²ΡΡ ΡΡΡΠΎΠΊΡ.unnest_wider()
Π±Π΅ΡΠ΅Ρ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΡΠΏΠΈΡΠΊΠ°-ΡΡΠΎΠ»Π±ΡΠ° ΠΈ ΡΠΎΠ·Π΄Π°Π΅Ρ Π½ΠΎΠ²ΡΠΉ ΡΡΠΎΠ»Π±Π΅Ρ.unnest_auto()
Π°Π²ΡΠΎΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅Ρ ΠΊΠ°ΠΊΡΡ ΠΈΠ· ΡΡΠ½ΠΊΡΠΈΠΉ Π»ΡΡΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ
unnest_longer()
ΠΈΠ»ΠΈunnest_wider()
.hoist()
ΠΏΠΎΡ ΠΎΠΆΠ° Π½Π°unnest_wider()
Π½ΠΎ ΠΎΡΠ±ΠΈΡΠ°Π΅Ρ ΡΠΎΠ»ΡΠΊΠΎ ΡΠΊΠ°Π·Π°Π½Π½ΡΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΠΈ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ ΡΠ°Π±ΠΎΡΠ°ΡΡ Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΡΡΠΎΠ²Π½ΡΠΌΠΈ Π²Π»ΠΎΠΆΠ΅Π½Π½ΠΎΡΡΠΈ.
ΠΠΎΠ»ΡΡΠΈΠ½ΡΡΠ²ΠΎ ΠΏΡΠΎΠ±Π»Π΅ΠΌ ΡΠ²ΡΠ·Π°Π½Π½ΡΡ Ρ ΠΏΡΠΈΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ΠΌ Π½Π΅ ΡΡΡΡΠΊΡΡΡΠΈΡΠΎΠ²Π°Π½Π½ΡΡ Π΄Π°Π½Π½ΡΡ Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΠΌΠΈ ΡΡΠΎΠ²Π½ΡΠΌΠΈ Π²Π»ΠΎΠΆΠ΅Π½Π½ΠΎΡΡΠΈ ΠΊ Π΄Π²ΡΡ ΠΌΠ΅ΡΠ½ΠΎΠΉ ΡΠ°Π±Π»ΠΈΡΠ΅ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ΅ΡΠΈΡΡ, ΠΊΠΎΠΌΠ±ΠΈΠ½ΠΈΡΡΡ ΠΏΠ΅ΡΠ΅ΡΠΈΡΠ»Π΅Π½Π½ΡΠ΅ ΡΡΠ½ΠΊΡΠΈΠΈ Ρ dplyr.
ΠΠ»Ρ Π΄Π΅ΠΌΠΎΠ½ΡΡΡΠ°ΡΠΈΠΈ ΡΡΠΈΡ
ΠΏΡΠΈΠ΅ΠΌΠΎΠ², ΠΌΡ Π±ΡΠ΄Π΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ ΠΏΠ°ΠΊΠ΅Ρ repurrrsive
, ΠΊΠΎΡΠΎΡΡΠΉ ΠΏΡΠ΅Π΄ΠΎΡΡΠ°Π²Π»ΡΠ΅Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ»ΠΎΠΆΠ½ΡΡ
, ΠΌΠ½ΠΎΠ³ΠΎΡΡΠΎΠ²Π½Π΅Π²ΡΡ
ΡΠΏΠΈΡΠΊΠΎΠ², ΠΏΠΎΠ»ΡΡΠ΅Π½Π½ΡΡ
ΠΈΠ· Π²Π΅Π±-API.
library(tidyr)
library(dplyr)
library(repurrrsive)
ΠΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΠΈ GitHub
ΠΠ°ΡΠ½Π΅ΠΌ Ρ gh_users, ΡΠΏΠΈΡΠΊΠ°, ΠΊΠΎΡΠΎΡΡΠΉ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΠ΅ΡΡΠΈ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡ GitHub. ΠΠ»Ρ Π½Π°ΡΠ°Π»Π° ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΠ΅ΠΌ ΡΠΏΠΈΡΠΎΠΊ gh_users Π² tibble ΡΡΠ΅ΠΉΠΌ.:
users <- tibble( user = gh_users )
ΠΡΠΎ ΠΊΠ°ΠΆΠ΅ΡΡΡ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ Π½Π΅Π»ΠΎΠ³ΠΈΡΠ½ΡΠΌ: Π·Π°ΡΠ΅ΠΌ ΠΏΡΠΈΠ²ΠΎΠ΄ΠΈΡΡ ΡΠΏΠΈΡΠΎΠΊ gh_users, ΠΊ Π±ΠΎΠ»Π΅Π΅ ΡΠ»ΠΎΠΆΠ½ΠΎΠΉ ΡΡΡΡΠΊΡΡΡΠ΅ Π΄Π°Π½Π½ΡΡ ? ΠΠΎ Ρ Π΄Π°ΡΠ° ΡΡΠ΅ΠΉΠΌΠ° Π΅ΡΡΡ Π±ΠΎΠ»ΡΡΠΎΠ΅ ΠΏΡΠ΅ΠΈΠΌΡΡΠ΅ΡΡΠ²ΠΎ: ΠΎΠ½ ΠΎΠ±ΡΠ΅Π΄ΠΈΠ½ΡΠ΅Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ Π²Π΅ΠΊΡΠΎΡΠΎΠ², ΡΠ°ΠΊ ΡΡΠΎ Π²ΡΠ΅ ΠΎΡΡΠ»Π΅ΠΆΠΈΠ²Π°Π΅ΡΡΡ Π² ΠΎΠ΄Π½ΠΎΠΌ ΠΎΠ±ΡΠ΅ΠΊΡΠ΅.
ΠΠ°ΠΆΠ΄ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΎΠ±ΡΠ΅ΠΊΡΠ° users
ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΠΎΠ±ΠΎΠΉ ΠΈΠΌΠ΅Π½ΠΎΠ²Π°Π½Π½ΡΠΉ ΡΠΏΠΈΡΠΎΠΊ, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΠ΅Ρ ΡΡΠΎΠ»Π±Π΅Ρ.
names(users$user[[1]])
#> [1] "login" "id" "avatar_url"
#> [4] "gravatar_id" "url" "html_url"
#> [7] "followers_url" "following_url" "gists_url"
#> [10] "starred_url" "subscriptions_url" "organizations_url"
#> [13] "repos_url" "events_url" "received_events_url"
#> [16] "type" "site_admin" "name"
#> [19] "company" "blog" "location"
#> [22] "email" "hireable" "bio"
#> [25] "public_repos" "public_gists" "followers"
#> [28] "following" "created_at" "updated_at"
ΠΡΡΡ Π΄Π²Π° ΡΠΏΠΎΡΠΎΠ±Π° ΠΏΡΠ΅Π²ΡΠ°ΡΠΈΡΡ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΡΠΏΠΈΡΠΊΠ° Π² ΡΡΠΎΠ»Π±ΡΡ. unnest_wider()
Π±Π΅ΡΠ΅Ρ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ ΠΈ ΡΠΎΠ·Π΄Π°Π΅Ρ Π½ΠΎΠ²ΡΠΉ ΡΡΠΎΠ»Π±Π΅Ρ:
users %>% unnest_wider(user)
#> # A tibble: 6 x 30
#> login id avatar_url gravatar_id url html_url followers_url
#> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 gaboβ¦ 6.60e5 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 2 jennβ¦ 5.99e5 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 3 jtleβ¦ 1.57e6 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 4 juliβ¦ 1.25e7 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 5 leepβ¦ 3.51e6 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 6 masaβ¦ 8.36e6 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> # β¦ with 23 more variables: following_url <chr>, gists_url <chr>,
#> # starred_url <chr>, subscriptions_url <chr>, organizations_url <chr>,
#> # repos_url <chr>, events_url <chr>, received_events_url <chr>,
#> # type <chr>, site_admin <lgl>, name <chr>, company <chr>, blog <chr>,
#> # location <chr>, email <chr>, public_repos <int>, public_gists <int>,
#> # followers <int>, following <int>, created_at <chr>, updated_at <chr>,
#> # bio <chr>, hireable <lgl>
Π ΡΡΠΎΠΌ ΡΠ»ΡΡΠ°Π΅ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠ»ΠΈ ΡΠ°Π±Π»ΠΈΡΡ ΡΠΎΡΡΠΎΡΡΡΡ ΠΈΠ· 30 ΡΡΠΎΠ»Π±ΡΠΎΠ², ΠΈ Π±ΠΎΠ»ΡΡΠΈΠ½ΡΡΠ²ΠΎ ΠΈΠ· Π½ΠΈΡ
Π½Π°ΠΌ Π½Π΅ ΠΏΠΎΠ½Π°Π΄ΠΎΠ±ΡΡΡΡ, ΠΏΠΎΡΡΠΎΠΌΡ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ Π²ΠΌΠ΅ΡΡΠΎ unnest_wider()
ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ hoist()
. hoist()
ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π½Π°ΠΌ ΠΈΠ·Π²Π»Π΅ΠΊΠ°ΡΡ Π²ΡΠ±ΡΠ°Π½Π½ΡΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ, ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΡΠΎΡ ΠΆΠ΅ ΡΠΈΠ½ΡΠ°ΠΊΡΠΈΡ, ΡΡΠΎ ΠΈ purrr::pluck()
:
users %>% hoist(user,
followers = "followers",
login = "login",
url = "html_url"
)
#> # A tibble: 6 x 4
#> followers login url user
#> <int> <chr> <chr> <list>
#> 1 303 gaborcsardi https://github.com/gaborcsardi <named list [27]>
#> 2 780 jennybc https://github.com/jennybc <named list [27]>
#> 3 3958 jtleek https://github.com/jtleek <named list [27]>
#> 4 115 juliasilge https://github.com/juliasilge <named list [27]>
#> 5 213 leeper https://github.com/leeper <named list [27]>
#> 6 34 masalmon https://github.com/masalmon <named list [27]>
hoist()
ΡΠ΄Π°Π»ΡΠ΅Ρ ΡΠΊΠ°Π·Π°Π½Π½ΡΠ΅ ΠΈΠΌΠ΅Π½ΠΎΠ²Π°Π½Π½ΡΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΠΈΠ· ΡΠΏΠΈΡΠΊΠ°-ΡΡΠΎΠ»Π±ΡΠ° user, ΠΏΠΎΡΡΠΎΠΌΡ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΡΠ°ΡΡΠΌΠ°ΡΡΠΈΠ²Π°ΡΡ hoist()
ΠΊΠ°ΠΊ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΠΎΠ² ΠΈΠ· Π²Π½ΡΡΡΠ΅Π½Π½Π΅Π³ΠΎ ΡΠΏΠΈΡΠΊΠ° Π΄Π°ΡΠ° ΡΡΠ΅ΠΉΠΌΠ° ΠΊ Π΅Π³ΠΎ Π²Π΅ΡΡ
Π½Π΅ΠΌΡ ΡΡΠΎΠ²Π½Ρ.
Π Π΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΈ Github
ΠΡΡΠ°Π²Π½ΠΈΠ²Π°Π½ΠΈΠ΅ ΡΠΏΠΈΡΠΊΠ° gh_repos
ΠΌΡ Π½Π°ΡΠΈΠ½Π°Π΅ΠΌ Π°Π½Π°Π»ΠΎΠ³ΠΈΡΠ½ΠΎ, ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΡ Π΅Π³ΠΎ Π² tibble
:
repos <- tibble(repo = gh_repos)
repos
#> # A tibble: 6 x 1
#> repo
#> <list>
#> 1 <list [30]>
#> 2 <list [30]>
#> 3 <list [30]>
#> 4 <list [26]>
#> 5 <list [30]>
#> 6 <list [30]>
ΠΠ° ΡΡΠΎΡ ΡΠ°Π· ΡΠ»Π΅ΠΌΠ΅Π½ΡΡ user ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΡΡ ΡΠΎΠ±ΠΎΠΉ ΡΠΏΠΈΡΠΎΠΊ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠ΅Π², ΠΏΡΠΈΠ½Π°Π΄Π»Π΅ΠΆΠ°ΡΠΈΡ
ΡΡΠΎΠΌΡ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»Ρ. ΠΠ°ΠΆΠ΄ΡΠΉ ΡΠ΅ΠΏΠΎΠ·ΠΈΡΠΎΡΠΈΠΉ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΠΌ Π½Π°Π±Π»ΡΠ΄Π΅Π½ΠΈΠ΅ΠΌ, ΠΏΠΎΡΡΠΎΠΌΡ ΡΠΎΠ³Π»Π°ΡΠ½ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΏΡΠΈΠΈ Π°ΠΊΠΊΡΡΠ°ΡΠ½ΡΡ
Π΄Π°Π½Π½ΡΡ
(ΠΏΡΠΈΠΌ. tidy data) ΠΎΠ½ΠΈ Π΄ΠΎΠ»ΠΆΠ½Ρ ΡΡΠ°ΡΡ Π½ΠΎΠ²ΡΠΌΠΈ ΡΡΡΠΎΠΊΠ°ΠΌΠΈ, Π² ΡΠ²ΡΠ·ΠΈ Ρ ΡΠ΅ΠΌ ΠΌΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌ unnest_longer()
Π° Π½Π΅ unnest_wider()
:
repos <- repos %>% unnest_longer(repo)
repos
#> # A tibble: 176 x 1
#> repo
#> <list>
#> 1 <named list [68]>
#> 2 <named list [68]>
#> 3 <named list [68]>
#> 4 <named list [68]>
#> 5 <named list [68]>
#> 6 <named list [68]>
#> 7 <named list [68]>
#> 8 <named list [68]>
#> 9 <named list [68]>
#> 10 <named list [68]>
#> # β¦ with 166 more rows
Π’Π΅ΠΏΠ΅ΡΡ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ unnest_wider()
ΠΈΠ»ΠΈ hoist()
:
repos %>% hoist(repo,
login = c("owner", "login"),
name = "name",
homepage = "homepage",
watchers = "watchers_count"
)
#> # A tibble: 176 x 5
#> login name homepage watchers repo
#> <chr> <chr> <chr> <int> <list>
#> 1 gaborcsardi after <NA> 5 <named list [65]>
#> 2 gaborcsardi argufy <NA> 19 <named list [65]>
#> 3 gaborcsardi ask <NA> 5 <named list [65]>
#> 4 gaborcsardi baseimports <NA> 0 <named list [65]>
#> 5 gaborcsardi citest <NA> 0 <named list [65]>
#> 6 gaborcsardi clisymbols "" 18 <named list [65]>
#> 7 gaborcsardi cmaker <NA> 0 <named list [65]>
#> 8 gaborcsardi cmark <NA> 0 <named list [65]>
#> 9 gaborcsardi conditions <NA> 0 <named list [65]>
#> 10 gaborcsardi crayon <NA> 52 <named list [65]>
#> # β¦ with 166 more rows
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅ Π½Π° ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ c("owner", "login")
: ΡΡΠΎ ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π½Π°ΠΌ ΠΏΠΎΠ»ΡΡΠΈΡΡ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅ Π²ΡΠΎΡΠΎΠ³ΠΎ ΡΡΠΎΠ²Π½Ρ ΠΈΠ· Π²Π»ΠΎΠΆΠ΅Π½Π½ΠΎΠ³ΠΎ ΡΠΏΠΈΡΠΊΠ° owner
. ΠΠ»ΡΡΠ΅ΡΠ½Π°ΡΠΈΠ²Π½ΡΠΉ ΠΏΠΎΠ΄Ρ
ΠΎΠ΄ ΡΠΎΡΡΠΎΠΈΡ Π² ΡΠΎΠΌ, ΡΡΠΎΠ±Ρ ΠΏΠΎΠ»ΡΡΠΈΡΡ Π²Π΅ΡΡ ΡΠΏΠΈΡΠΎΠΊ owner
ΠΈ Π·Π°ΡΠ΅ΠΌ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΡΠ½ΠΊΡΠΈΠΈ unnest_wider()
ΠΏΠΎΠΌΠ΅ΡΡΠΈΡΡ ΠΊΠ°ΠΆΠ΄ΡΠΉ Π΅Π³ΠΎ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Π² ΡΡΠΎΠ»Π±Π΅Ρ:
repos %>%
hoist(repo, owner = "owner") %>%
unnest_wider(owner)
#> # A tibble: 176 x 18
#> login id avatar_url gravatar_id url html_url followers_url
#> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 2 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 3 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 4 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 5 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 6 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 7 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 8 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 9 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> 10 gaboβ¦ 660288 https://aβ¦ "" httpβ¦ https:/β¦ https://api.β¦
#> # β¦ with 166 more rows, and 11 more variables: following_url <chr>,
#> # gists_url <chr>, starred_url <chr>, subscriptions_url <chr>,
#> # organizations_url <chr>, repos_url <chr>, events_url <chr>,
#> # received_events_url <chr>, type <chr>, site_admin <lgl>, repo <list>
ΠΠΌΠ΅ΡΡΠΎ ΡΠΎΠ³ΠΎ, ΡΡΠΎ Π±Ρ ΡΠ°Π·ΠΌΡΡΠ»ΡΡΡ Π½Π°Π΄ Π²ΡΠ±ΠΎΡΠΎΠΌ Π½ΡΠΆΠ½ΠΎΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ unnest_longer()
ΠΈΠ»ΠΈ unnest_wider()
Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ unnest_auto()
. ΠΡΠ° ΡΡΠ½ΠΊΡΠΈΡ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅Ρ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ²ΡΠΈΡΡΠΈΡΠ΅ΡΠΊΠΈΡ
ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ² Π΄Π»Ρ ΠΏΠΎΠ΄Π±ΠΎΡΠ° Π½Π°ΠΈΠ±ΠΎΠ»Π΅Π΅ ΠΏΠΎΠ΄Ρ
ΠΎΠ΄ΡΡΠ΅ΠΉ ΡΡΠ½ΠΊΡΠΈΠΈ Π΄Π»Ρ ΡΡΠ°Π½ΡΡΠΎΡΠΌΠ°ΡΠΈΠΈ Π΄Π°Π½Π½ΡΡ
, ΠΈ Π²ΡΠ²ΠΎΠ΄ΠΈΡ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ ΠΎ Π²ΡΠ±ΡΠ°Π½Π½ΠΎΠΌ ΡΠΏΠΎΡΠΎΠ±Π΅.
tibble(repo = gh_repos) %>%
unnest_auto(repo) %>%
unnest_auto(repo)
#> Using `unnest_longer(repo)`; no element has names
#> Using `unnest_wider(repo)`; elements have 68 names in common
#> # A tibble: 176 x 67
#> id name full_name owner private html_url description fork url
#> <int> <chr> <chr> <lis> <lgl> <chr> <chr> <lgl> <chr>
#> 1 6.12e7 after gaborcsaβ¦ <namβ¦ FALSE https:/β¦ Run Code iβ¦ FALSE httpβ¦
#> 2 4.05e7 arguβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ Declarativβ¦ FALSE httpβ¦
#> 3 3.64e7 ask gaborcsaβ¦ <namβ¦ FALSE https:/β¦ Friendly Cβ¦ FALSE httpβ¦
#> 4 3.49e7 baseβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ Do we get β¦ FALSE httpβ¦
#> 5 6.16e7 citeβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ Test R pacβ¦ TRUE httpβ¦
#> 6 3.39e7 clisβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ Unicode syβ¦ FALSE httpβ¦
#> 7 3.72e7 cmakβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ port of cmβ¦ TRUE httpβ¦
#> 8 6.80e7 cmark gaborcsaβ¦ <namβ¦ FALSE https:/β¦ CommonMarkβ¦ TRUE httpβ¦
#> 9 6.32e7 condβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ <NA> TRUE httpβ¦
#> 10 2.43e7 crayβ¦ gaborcsaβ¦ <namβ¦ FALSE https:/β¦ R package β¦ FALSE httpβ¦
#> # β¦ with 166 more rows, and 58 more variables: forks_url <chr>,
#> # keys_url <chr>, collaborators_url <chr>, teams_url <chr>,
#> # hooks_url <chr>, issue_events_url <chr>, events_url <chr>,
#> # assignees_url <chr>, branches_url <chr>, tags_url <chr>,
#> # blobs_url <chr>, git_tags_url <chr>, git_refs_url <chr>,
#> # trees_url <chr>, statuses_url <chr>, languages_url <chr>,
#> # stargazers_url <chr>, contributors_url <chr>, subscribers_url <chr>,
#> # subscription_url <chr>, commits_url <chr>, git_commits_url <chr>,
#> # comments_url <chr>, issue_comment_url <chr>, contents_url <chr>,
#> # compare_url <chr>, merges_url <chr>, archive_url <chr>,
#> # downloads_url <chr>, issues_url <chr>, pulls_url <chr>,
#> # milestones_url <chr>, notifications_url <chr>, labels_url <chr>,
#> # releases_url <chr>, deployments_url <chr>, created_at <chr>,
#> # updated_at <chr>, pushed_at <chr>, git_url <chr>, ssh_url <chr>,
#> # clone_url <chr>, svn_url <chr>, size <int>, stargazers_count <int>,
#> # watchers_count <int>, language <chr>, has_issues <lgl>,
#> # has_downloads <lgl>, has_wiki <lgl>, has_pages <lgl>,
#> # forks_count <int>, open_issues_count <int>, forks <int>,
#> # open_issues <int>, watchers <int>, default_branch <chr>,
#> # homepage <chr>
ΠΠ΅ΡΡΠΎΠ½Π°ΠΆΠΈ ΠΠ³ΡΡ ΠΡΠ΅ΡΡΠΎΠ»ΠΎΠ²
got_chars
ΠΈΠΌΠ΅Π΅Ρ ΠΈΠ΄Π΅Π½ΡΠΈΡΠ½ΡΡ ΡΡΡΡΠΊΡΡΡΡ Ρ gh_users
: ΡΡΠΎ Π½Π°Π±ΠΎΡ ΠΈΠΌΠ΅Π½ΠΎΠ²Π°Π½Π½ΡΡ
ΡΠΏΠΈΡΠΊΠΎΠ², Π³Π΄Π΅ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Π²Π½ΡΡΡΠ΅Π½Π½Π΅Π³ΠΎ ΡΠΏΠΈΡΠΊΠ° ΠΎΠΏΠΈΡΡΠ²Π°Π΅Ρ Π½Π΅ΠΊΠΎΡΠΎΡΡΠΉ Π°ΡΡΠΈΠ±ΡΡ ΠΏΠ΅ΡΡΠΎΠ½Π°ΠΆΠ° ΠΠ³ΡΡ ΠΡΠ΅ΡΡΠΎΠ»ΠΎΠ². ΠΡΠΈΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ got_chars
ΠΊ ΡΠ°Π±Π»ΠΈΡΠ½ΠΎΠΌΡ Π²ΠΈΠ΄Ρ ΠΌΡ Π½Π°ΡΠΈΠ½Π°Π΅ΠΌ Ρ ΡΠΎΠ·Π΄Π°Π½ΠΈΡ Π΄Π°ΡΠ° ΡΡΠ΅ΠΉΠΌΠ°, ΡΠ°ΠΊ ΠΆΠ΅ ΠΊΠ°ΠΊ ΠΈ Π² ΠΏΡΠΈΠ²Π΅Π΄ΡΠ½Π½ΡΡ
ΡΠ°Π½Π΅Π΅ ΠΏΡΠΈΠΌΠ΅ΡΠ°Ρ
, Π° Π·Π°ΡΠ΅ΠΌ ΠΏΠ΅ΡΠ΅Π²Π΅Π΄ΡΠΌ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΡΠ»Π΅ΠΌΠ΅Π½Ρ Π² ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΠΉ ΡΡΠΎΠ»Π±Π΅Ρ:
chars <- tibble(char = got_chars)
chars
#> # A tibble: 30 x 1
#> char
#> <list>
#> 1 <named list [18]>
#> 2 <named list [18]>
#> 3 <named list [18]>
#> 4 <named list [18]>
#> 5 <named list [18]>
#> 6 <named list [18]>
#> 7 <named list [18]>
#> 8 <named list [18]>
#> 9 <named list [18]>
#> 10 <named list [18]>
#> # β¦ with 20 more rows
chars2 <- chars %>% unnest_wider(char)
chars2
#> # A tibble: 30 x 18
#> url id name gender culture born died alive titles aliases father
#> <chr> <int> <chr> <chr> <chr> <chr> <chr> <lgl> <list> <list> <chr>
#> 1 http⦠1022 Theo⦠Male Ironbo⦠In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> 2 http⦠1052 Tyri⦠Male "" In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> 3 http⦠1074 Vict⦠Male Ironbo⦠In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> 4 http⦠1109 Will Male "" "" In 2⦠FALSE <chr ⦠<chr [⦠""
#> 5 http⦠1166 Areo⦠Male Norvos⦠In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> 6 http⦠1267 Chett Male "" At H⦠In 2⦠FALSE <chr ⦠<chr [⦠""
#> 7 http⦠1295 Cres⦠Male "" In 2⦠In 2⦠FALSE <chr ⦠<chr [⦠""
#> 8 http⦠130 Aria⦠Female Dornish In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> 9 http⦠1303 Daen⦠Female Valyri⦠In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> 10 http⦠1319 Davo⦠Male Wester⦠In 2⦠"" TRUE <chr ⦠<chr [⦠""
#> # β¦ with 20 more rows, and 7 more variables: mother <chr>, spouse <chr>,
#> # allegiances <list>, books <list>, povBooks <list>, tvSeries <list>,
#> # playedBy <list>
Π‘ΡΡΡΠΊΡΡΡΠ° got_chars
Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΎ ΡΠ»ΠΎΠΆΠ½Π΅Π΅, ΡΠ΅ΠΌ gh_users
, Ρ.ΠΊ. Π½Π΅ΠΊΠΎΡΠΎΡΡΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ ΡΠΏΠΈΡΠΊΠ° char
ΡΠ°ΠΌΠΈ ΠΏΠΎ ΡΠ΅Π±Π΅ ΡΠ²Π»ΡΡΡΡΡ ΡΠΏΠΈΡΠΊΠΎΠΌ, Π² ΡΠ΅Π·ΡΠ»ΡΡΠ°ΡΠ΅ ΠΌΡ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ ΡΡΠΎΠ»Π±Ρ β ΡΠΏΠΈΡΠΊΠΈ:
chars2 %>% select_if(is.list)
#> # A tibble: 30 x 7
#> titles aliases allegiances books povBooks tvSeries playedBy
#> <list> <list> <list> <list> <list> <list> <list>
#> 1 <chr [3]> <chr [4]> <chr [1]> <chr [3]> <chr [2]> <chr [6]> <chr [1]>
#> 2 <chr [2]> <chr [11]> <chr [1]> <chr [2]> <chr [4]> <chr [6]> <chr [1]>
#> 3 <chr [2]> <chr [1]> <chr [1]> <chr [3]> <chr [2]> <chr [1]> <chr [1]>
#> 4 <chr [1]> <chr [1]> <???> <chr [1]> <chr [1]> <chr [1]> <chr [1]>
#> 5 <chr [1]> <chr [1]> <chr [1]> <chr [3]> <chr [2]> <chr [2]> <chr [1]>
#> 6 <chr [1]> <chr [1]> <???> <chr [2]> <chr [1]> <chr [1]> <chr [1]>
#> 7 <chr [1]> <chr [1]> <???> <chr [2]> <chr [1]> <chr [1]> <chr [1]>
#> 8 <chr [1]> <chr [1]> <chr [1]> <chr [4]> <chr [1]> <chr [1]> <chr [1]>
#> 9 <chr [5]> <chr [11]> <chr [1]> <chr [1]> <chr [4]> <chr [6]> <chr [1]>
#> 10 <chr [4]> <chr [5]> <chr [2]> <chr [1]> <chr [3]> <chr [5]> <chr [1]>
#> # β¦ with 20 more rows
ΠΠ°ΡΠΈ Π΄Π°Π»ΡΠ½Π΅ΠΉΡΠΈΠ΅ Π΄Π΅ΠΉΡΡΠ²ΠΈΡ Π·Π°Π²ΠΈΡΡΡ ΠΎΡ ΡΠ΅Π»Π΅ΠΉ Π°Π½Π°Π»ΠΈΠ·Π°. ΠΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎ, Π²Π°ΠΌ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎ ΠΏΠΎΠΌΠ΅ΡΡΠΈΡΡ Π² ΡΡΡΠΎΠΊΠΈ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΏΠΎ ΠΊΠ°ΠΆΠ΄ΠΎΠΉ ΠΊΠ½ΠΈΠ³Π΅ ΠΈ ΡΠ΅ΡΠΈΠ°Π»Π΅, Π² ΠΊΠΎΡΠΎΡΠΎΠΌ ΠΏΠΎΡΠ²Π»ΡΠ΅ΡΡΡ ΠΏΠ΅ΡΡΠΎΠ½Π°ΠΆ:
chars2 %>%
select(name, books, tvSeries) %>%
pivot_longer(c(books, tvSeries), names_to = "media", values_to = "value") %>%
unnest_longer(value)
#> # A tibble: 180 x 3
#> name media value
#> <chr> <chr> <chr>
#> 1 Theon Greyjoy books A Game of Thrones
#> 2 Theon Greyjoy books A Storm of Swords
#> 3 Theon Greyjoy books A Feast for Crows
#> 4 Theon Greyjoy tvSeries Season 1
#> 5 Theon Greyjoy tvSeries Season 2
#> 6 Theon Greyjoy tvSeries Season 3
#> 7 Theon Greyjoy tvSeries Season 4
#> 8 Theon Greyjoy tvSeries Season 5
#> 9 Theon Greyjoy tvSeries Season 6
#> 10 Tyrion Lannister books A Feast for Crows
#> # β¦ with 170 more rows
ΠΠ»ΠΈ, ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ, Π²Ρ Ρ ΠΎΡΠΈΡΠ΅ ΡΠΎΠ·Π΄Π°ΡΡ ΡΠ°Π±Π»ΠΈΡΡ, ΠΊΠΎΡΠΎΡΠ°Ρ ΠΏΠΎΠ·Π²ΠΎΠ»ΠΈΡ Π²Π°ΠΌ ΡΠΎΠΏΠΎΡΡΠ°Π²ΠΈΡΡ ΠΏΠ΅ΡΡΠΎΠ½Π°ΠΆΠ° ΠΈ ΠΏΡΠΎΠΈΠ·Π²Π΅Π΄Π΅Π½ΠΈΠ΅:
chars2 %>%
select(name, title = titles) %>%
unnest_longer(title)
#> # A tibble: 60 x 2
#> name title
#> <chr> <chr>
#> 1 Theon Greyjoy Prince of Winterfell
#> 2 Theon Greyjoy Captain of Sea Bitch
#> 3 Theon Greyjoy Lord of the Iron Islands (by law of the green lands)
#> 4 Tyrion Lannister Acting Hand of the King (former)
#> 5 Tyrion Lannister Master of Coin (former)
#> 6 Victarion Greyjoy Lord Captain of the Iron Fleet
#> 7 Victarion Greyjoy Master of the Iron Victory
#> 8 Will ""
#> 9 Areo Hotah Captain of the Guard at Sunspear
#> 10 Chett ""
#> # β¦ with 50 more rows
(ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, Π½Π° ΠΏΡΡΡΡΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΡ ""
Π² ΠΏΠΎΠ»Π΅ title
, ΡΡΠΎ ΡΠ²ΡΠ·Π°Π½ΠΎ Ρ ΠΎΡΠΈΠ±ΠΊΠ°ΠΌΠΈ Π΄ΠΎΠΏΡΡΠ΅Π½Π½ΡΠΌΠΈ ΠΏΡΠΈ Π²Π²ΠΎΠ΄Π΅ Π΄Π°Π½Π½ΡΡ
Π² got_chars
: Π½Π° ΡΠ°ΠΌΠΎΠΌ Π΄Π΅Π»Π΅ ΠΏΠ΅ΡΡΠΎΠ½Π°ΠΆΠΈ Π΄Π»Ρ ΠΊΠΎΡΠΎΡΡΡ
Π½Π΅Ρ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠΈΡ
Π·Π°Π³ΠΎΠ»ΠΎΠ²ΠΊΠΎΠ² ΠΊΠ½ΠΈΠ³ ΠΈ ΡΠ΅ΡΠΈΠ°Π»ΠΎΠ² Π² ΠΏΠΎΠ»Π΅ title
Π΄ΠΎΠ»ΠΆΠ½Ρ ΠΈΠΌΠ΅ΡΡ Π²Π΅ΠΊΡΠΎΡ Π΄Π»ΠΈΠ½Ρ 0, Π° Π½Π΅ Π²Π΅ΠΊΡΠΎΡ Π΄Π»ΠΈΠ½Ρ 1, ΡΠΎΠ΄Π΅ΡΠΆΠ°ΡΠΈΠΉ ΠΏΡΡΡΡΡ ΡΡΡΠΎΠΊΡ.)
ΠΡ ΠΌΠΎΠΆΠ΅ΠΌ ΠΏΠ΅ΡΠ΅ΠΏΠΈΡΠ°ΡΡ ΠΏΡΠΈΠ²Π΅Π΄ΡΠ½Π½ΡΠΉ Π²ΡΡΠ΅ ΠΏΡΠΈΠΌΠ΅Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ ΡΡΠ½ΠΊΡΠΈΡ unnest_auto()
. ΠΡΠΎΡ ΠΏΠΎΠ΄Ρ
ΠΎΠ΄ ΡΠ΄ΠΎΠ±Π΅Π½ Π΄Π»Ρ ΡΠ°Π·ΠΎΠ²ΠΎΠ³ΠΎ Π°Π½Π°Π»ΠΈΠ·Π°, Π½ΠΎ Π½Π΅ ΡΡΠΎΠΈΡ ΠΏΠΎΠ»Π°Π³Π°ΡΡΡΡ Π½Π° unnest_auto()
Π΄Π»Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΡ Π½Π° ΡΠ΅Π³ΡΠ»ΡΡΠ½ΠΎΠΉ ΠΎΡΠ½ΠΎΠ²Π΅. ΠΠ΅Π»ΠΎ Π² ΡΠΎΠΌ, ΡΡΠΎ Π΅ΡΠ»ΠΈ Π²Π°ΡΠ° ΡΡΡΡΠΊΡΡΡΠ° Π΄Π°Π½Π½ΡΡ
ΠΈΠ·ΠΌΠ΅Π½ΠΈΡΡΡ unnest_auto()
ΠΌΠΎΠΆΠ΅Ρ ΠΏΠΎΠΌΠ΅Π½ΡΡΡ Π²ΡΠ±ΡΠ°Π½Π½ΡΠΉ ΠΌΠ΅Ρ
Π°Π½ΠΈΠ·ΠΌ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΠΎΠ²Π°Π½ΠΈΡ Π΄Π°Π½Π½ΡΡ
, Π΅ΡΠ»ΠΈ ΠΈΠ·Π½Π°ΡΠ°Π»ΡΠ½ΠΎ ΠΎΠ½ ΡΠ°Π·Π²ΠΎΡΠ°ΡΠΈΠ²Π°Π» ΡΡΠΎΠ»Π±ΡΡ-ΡΠΏΠΈΡΠΊΠΈ Π² ΡΡΡΠΎΠΊΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΡ unnest_longer()
, ΡΠΎ ΠΏΡΠΈ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠΈ ΡΡΡΡΠΊΡΡΡΡ Π²Ρ
ΠΎΠ΄ΡΡΠΈΡ
Π΄Π°Π½Π½ΡΡ
Π»ΠΎΠ³ΠΈΠΊΠ° ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½Π° Π² ΠΏΠΎΠ»ΡΠ·Ρ unnest_wider()
, ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°Π½ΠΈΠ΅ ΡΠ°ΠΊΠΎΠ³ΠΎ ΠΏΠΎΠ΄Ρ
ΠΎΠ΄Π° Π½Π° ΠΏΠΎΡΡΠΎΡΠ½Π½ΠΎΠΉ ΠΎΡΠ½ΠΎΠ²Π΅ ΠΌΠΎΠΆΠ΅Ρ ΠΏΡΠΈΠ²Π΅ΡΡΠΈ ΠΊ Π½Π΅ΠΏΡΠ΅Π΄Π²ΠΈΠ΄Π΅Π½Π½ΡΠΌ ΠΎΡΠΈΠ±ΠΊΠ°ΠΌ.
tibble(char = got_chars) %>%
unnest_auto(char) %>%
select(name, title = titles) %>%
unnest_auto(title)
#> Using `unnest_wider(char)`; elements have 18 names in common
#> Using `unnest_longer(title)`; no element has names
#> # A tibble: 60 x 2
#> name title
#> <chr> <chr>
#> 1 Theon Greyjoy Prince of Winterfell
#> 2 Theon Greyjoy Captain of Sea Bitch
#> 3 Theon Greyjoy Lord of the Iron Islands (by law of the green lands)
#> 4 Tyrion Lannister Acting Hand of the King (former)
#> 5 Tyrion Lannister Master of Coin (former)
#> 6 Victarion Greyjoy Lord Captain of the Iron Fleet
#> 7 Victarion Greyjoy Master of the Iron Victory
#> 8 Will ""
#> 9 Areo Hotah Captain of the Guard at Sunspear
#> 10 Chett ""
#> # β¦ with 50 more rows
ΠΠ΅ΠΎΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Google
ΠΠ°Π»Π΅Π΅ ΠΌΡ ΡΠ°ΡΡΠΌΠΎΡΡΠΈΠΌ Π±ΠΎΠ»Π΅Π΅ ΡΠ»ΠΎΠΆΠ½ΡΡ ΡΡΡΡΠΊΡΡΡΡ Π΄Π°Π½Π½ΡΡ , ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌΡΡ ΠΎΡ ΡΠ»ΡΠΆΠ±Ρ Π³Π΅ΠΎΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΡ Google. ΠΡΡΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΡΡΡΡΠ½ΡΡ Π΄Π°Π½Π½ΡΡ ΠΏΡΠΎΡΠΈΠ²ΠΎΡΠ΅ΡΠΈΡ ΡΡΠ»ΠΎΠ²ΠΈΡΠΌ ΡΠ°Π±ΠΎΡΡ Ρ API Google maps, ΠΏΠΎΡΡΠΎΠΌΡ Ρ ΡΠ½Π°ΡΠ°Π»Π° Π½Π°ΠΏΠΈΡΡ ΠΏΡΠΎΡΡΡΡ ΠΎΠ±ΠΎΠ»ΠΎΡΠΊΡ ΠΊ API. ΠΠΎΡΠΎΡΠ°Ρ ΠΎΡΠ½ΠΎΠ²Π°Π½Π° Π½Π° Ρ ΡΠ°Π½Π΅Π½ΠΈΠΈ ΠΊΠ»ΡΡΠ° API Google ΠΊΠ°ΡΡ Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΠΎΠΉ ΡΡΠ΅Π΄Ρ; Π΅ΡΠ»ΠΈ Π² ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ ΡΡΠ΅Π΄Ρ Ρ Π²Π°Ρ Π½Π΅ ΡΠΎΡ ΡΠ°Π½ΡΠ½ ΠΊΠ»ΡΡ Π΄Π»Ρ ΡΠ°Π±ΠΎΡΡ Ρ API Google Maps, ΡΡΠ°Π³ΠΌΠ΅Π½ΡΡ ΠΊΠΎΠ΄Π° ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»Π΅Π½Π½ΡΠ΅ Π² ΡΡΠΎΠΌ ΡΠ°Π·Π΄Π΅Π»Π΅ Π²ΡΠΏΠΎΠ»Π½ΡΡΡΡΡ Π½Π΅ Π±ΡΠ΄ΡΡ.
has_key <- !identical(Sys.getenv("GOOGLE_MAPS_API_KEY"), "")
if (!has_key) {
message("No Google Maps API key found; code chunks will not be run")
}
# https://developers.google.com/maps/documentation/geocoding
geocode <- function(address, api_key = Sys.getenv("GOOGLE_MAPS_API_KEY")) {
url <- "https://maps.googleapis.com/maps/api/geocode/json"
url <- paste0(url, "?address=", URLencode(address), "&key=", api_key)
jsonlite::read_json(url)
}
Π‘ΠΏΠΈΡΠΎΠΊ, ΠΊΠΎΡΠΎΡΡΠΉ Π²ΠΎΠ·Π²ΡΠ°ΡΠ°Π΅Ρ ΡΡΠ° ΡΡΠ½ΠΊΡΠΈΡ, Π΄ΠΎΠ²ΠΎΠ»ΡΠ½ΠΎ ΡΠ»ΠΎΠΆΠ΅Π½:
houston <- geocode("Houston TX")
str(houston)
#> List of 2
#> $ results:List of 1
#> ..$ :List of 5
#> .. ..$ address_components:List of 4
#> .. .. ..$ :List of 3
#> .. .. .. ..$ long_name : chr "Houston"
#> .. .. .. ..$ short_name: chr "Houston"
#> .. .. .. ..$ types :List of 2
#> .. .. .. .. ..$ : chr "locality"
#> .. .. .. .. ..$ : chr "political"
#> .. .. ..$ :List of 3
#> .. .. .. ..$ long_name : chr "Harris County"
#> .. .. .. ..$ short_name: chr "Harris County"
#> .. .. .. ..$ types :List of 2
#> .. .. .. .. ..$ : chr "administrative_area_level_2"
#> .. .. .. .. ..$ : chr "political"
#> .. .. ..$ :List of 3
#> .. .. .. ..$ long_name : chr "Texas"
#> .. .. .. ..$ short_name: chr "TX"
#> .. .. .. ..$ types :List of 2
#> .. .. .. .. ..$ : chr "administrative_area_level_1"
#> .. .. .. .. ..$ : chr "political"
#> .. .. ..$ :List of 3
#> .. .. .. ..$ long_name : chr "United States"
#> .. .. .. ..$ short_name: chr "US"
#> .. .. .. ..$ types :List of 2
#> .. .. .. .. ..$ : chr "country"
#> .. .. .. .. ..$ : chr "political"
#> .. ..$ formatted_address : chr "Houston, TX, USA"
#> .. ..$ geometry :List of 4
#> .. .. ..$ bounds :List of 2
#> .. .. .. ..$ northeast:List of 2
#> .. .. .. .. ..$ lat: num 30.1
#> .. .. .. .. ..$ lng: num -95
#> .. .. .. ..$ southwest:List of 2
#> .. .. .. .. ..$ lat: num 29.5
#> .. .. .. .. ..$ lng: num -95.8
#> .. .. ..$ location :List of 2
#> .. .. .. ..$ lat: num 29.8
#> .. .. .. ..$ lng: num -95.4
#> .. .. ..$ location_type: chr "APPROXIMATE"
#> .. .. ..$ viewport :List of 2
#> .. .. .. ..$ northeast:List of 2
#> .. .. .. .. ..$ lat: num 30.1
#> .. .. .. .. ..$ lng: num -95
#> .. .. .. ..$ southwest:List of 2
#> .. .. .. .. ..$ lat: num 29.5
#> .. .. .. .. ..$ lng: num -95.8
#> .. ..$ place_id : chr "ChIJAYWNSLS4QIYROwVl894CDco"
#> .. ..$ types :List of 2
#> .. .. ..$ : chr "locality"
#> .. .. ..$ : chr "political"
#> $ status : chr "OK"
Π ΡΡΠ°ΡΡΡΡ, ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ ΠΏΠΎΡΠ°Π³ΠΎΠ²ΠΎ ΡΠ΅ΡΠΈΡΡ ΠΏΡΠΎΠ±Π»Π΅ΠΌΡ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΠΎΠ²Π°Π½ΠΈΡ ΡΡΠΈΡ
Π΄Π°Π½Π½ΡΡ
Π² ΡΠ°Π±Π»ΠΈΡΠ½ΡΠΉ Π²ΠΈΠ΄ Ρ ΠΏΠΎΠΌΠΎΡΡΡ ΡΡΠ½ΠΊΡΠΈΠΉ tidyr
. Π§ΡΠΎΠ±Ρ ΡΠ΄Π΅Π»Π°ΡΡ Π·Π°Π΄Π°ΡΡ Π½Π΅ΠΌΠ½ΠΎΠ³ΠΎ ΡΠ»ΠΎΠΆΠ½Π΅Π΅ ΠΈ ΡΠ΅Π°Π»ΠΈΡΡΠΈΡΠ½Π΅Π΅, Ρ Π½Π°ΡΠ½Ρ Ρ Π³Π΅ΠΎΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΡ Π½Π΅ΡΠΊΠΎΠ»ΡΠΊΠΈΡ
Π³ΠΎΡΠΎΠ΄ΠΎΠ²:
city <- c ( "Houston" , "LA" , "New York" , "Chicago" , "Springfield" ) city_geo <- purrr::map (city, geocode)
ΠΠΎΠ»ΡΡΠ΅Π½Π½ΡΠΉ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ Ρ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΡ Π² tibble
, Π΄Π»Ρ ΡΠ΄ΠΎΠ±ΡΡΠ²Π° Π΄ΠΎΠ±Π°Π²Π»Ρ ΡΡΠΎΠ»Π±Π΅Ρ Ρ ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠΈΠΌ Π½Π°Π·Π²Π°Π½ΠΈΠ΅ΠΌ Π³ΠΎΡΠΎΠ΄Π°.
loc <- tibble(city = city, json = city_geo)
loc
#> # A tibble: 5 x 2
#> city json
#> <chr> <list>
#> 1 Houston <named list [2]>
#> 2 LA <named list [2]>
#> 3 New York <named list [2]>
#> 4 Chicago <named list [2]>
#> 5 Springfield <named list [2]>
ΠΠ΅ΡΠ²ΡΠΉ ΡΡΠΎΠ²Π΅Π½Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ status
ΠΈ result
, ΠΊΠΎΡΠΎΡΡΠΉ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ ΡΠ°Π·Π²Π΅ΡΠ½ΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ unnest_wider()
:
loc %>%
unnest_wider(json)
#> # A tibble: 5 x 3
#> city results status
#> <chr> <list> <chr>
#> 1 Houston <list [1]> OK
#> 2 LA <list [1]> OK
#> 3 New York <list [1]> OK
#> 4 Chicago <list [1]> OK
#> 5 Springfield <list [1]> OK
ΠΠ±ΡΠ°ΡΠΈΡΠ΅ Π²Π½ΠΈΠΌΠ°Π½ΠΈΠ΅, ΡΡΠΎ results
ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΌΠ½ΠΎΠ³ΠΎΡΡΠΎΠ²Π½Π΅Π²ΡΠΌ ΡΠΏΠΈΡΠΊΠΎΠΌ. Π£ Π±ΠΎΠ»ΡΡΠΈΠ½ΡΡΠ²Π° Π³ΠΎΡΠΎΠ΄ΠΎΠ² Π΅ΡΡΡ 1 ΡΠ»Π΅ΠΌΠ΅Π½Ρ (ΠΏΡΠ΅Π΄ΡΡΠ°Π²Π»ΡΡΡΠΈΠΉ ΡΠ½ΠΈΠΊΠ°Π»ΡΠ½ΠΎΠ΅ Π·Π½Π°ΡΠ΅Π½ΠΈΠ΅, ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠ΅Π΅ API Π³Π΅ΠΎΠΊΠΎΠ΄ΠΈΡΠΎΠ²Π°Π½ΠΈΡ), Π½ΠΎ Ρ Π‘ΠΏΡΠΈΠ½Π³ΡΠΈΠ»Π΄Π° ΠΈΡ
Π΄Π²Π°. ΠΡ ΠΌΠΎΠΆΠ΅ΠΌ Π²ΡΡΠ°ΡΠΈΡΡ ΠΈΡ
Π² ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΠ΅ ΡΡΡΠΎΠΊΠΈ Ρ ΠΏΠΎΠΌΠΎΡΡΡ unnest_longer()
:
loc %>%
unnest_wider(json) %>%
unnest_longer(results)
#> # A tibble: 5 x 3
#> city results status
#> <chr> <list> <chr>
#> 1 Houston <named list [5]> OK
#> 2 LA <named list [5]> OK
#> 3 New York <named list [5]> OK
#> 4 Chicago <named list [5]> OK
#> 5 Springfield <named list [5]> OK
Π’Π΅ΠΏΠ΅ΡΡ Π²ΡΠ΅ ΠΎΠ½ΠΈ ΠΈΠΌΠ΅ΡΡ ΠΎΠ΄ΠΈΠ½Π°ΠΊΠΎΠ²ΡΠ΅ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½ΡΡ, Π² ΡΡΠΌ ΠΌΠΎΠΆΠ½ΠΎ ΡΠ±Π΅Π΄ΠΈΡΡΡΡ Ρ ΠΏΠΎΠΌΠΎΡΡΡ unnest_wider()
:
loc %>%
unnest_wider(json) %>%
unnest_longer(results) %>%
unnest_wider(results)
#> # A tibble: 5 x 7
#> city address_componen⦠formatted_addre⦠geometry place_id types status
#> <chr> <list> <chr> <list> <chr> <lis> <chr>
#> 1 Houst⦠<list [4]> Houston, TX, USA <named ⦠ChIJAYWN⦠<lis⦠OK
#> 2 LA <list [4]> Los Angeles, CA⦠<named ⦠ChIJE9on⦠<lis⦠OK
#> 3 New Y⦠<list [3]> New York, NY, U⦠<named ⦠ChIJOwg_⦠<lis⦠OK
#> 4 Chica⦠<list [4]> Chicago, IL, USA <named ⦠ChIJ7cv0⦠<lis⦠OK
#> 5 Sprin⦠<list [5]> Springfield, MO⦠<named ⦠ChIJP5jI⦠<lis⦠OK
ΠΡ ΠΌΠΎΠΆΠ΅ΠΌ Π½Π°ΠΉΡΠΈ ΠΊΠΎΠΎΡΠ΄ΠΈΠ½Π°ΡΡ ΡΠΈΡΠΎΡΡ ΠΈ Π΄ΠΎΠ»Π³ΠΎΡΡ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ Π³ΠΎΡΠΎΠ΄Π° ΡΠ°Π·Π²Π΅ΡΠ½ΡΠ² ΡΠΏΠΈΡΠΎΠΊ geometry
:
loc %>%
unnest_wider(json) %>%
unnest_longer(results) %>%
unnest_wider(results) %>%
unnest_wider(geometry)
#> # A tibble: 5 x 10
#> city address_compone⦠formatted_addre⦠bounds location location_type
#> <chr> <list> <chr> <list> <list> <chr>
#> 1 Hous⦠<list [4]> Houston, TX, USA <name⦠<named ⦠APPROXIMATE
#> 2 LA <list [4]> Los Angeles, CA⦠<name⦠<named ⦠APPROXIMATE
#> 3 New ⦠<list [3]> New York, NY, U⦠<name⦠<named ⦠APPROXIMATE
#> 4 Chic⦠<list [4]> Chicago, IL, USA <name⦠<named ⦠APPROXIMATE
#> 5 Spri⦠<list [5]> Springfield, MO⦠<name⦠<named ⦠APPROXIMATE
#> # β¦ with 4 more variables: viewport <list>, place_id <chr>, types <list>,
#> # status <chr>
Π Π·Π°ΡΠ΅ΠΌ ΠΌΠ΅ΡΡΠΎΠΏΠΎΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅, Π΄Π»Ρ ΡΠ΅Π³ΠΎ ΡΡΠ΅Π±ΡΠ΅ΡΡΡ ΡΠ°Π·Π²Π΅ΡΠ½ΡΡΡ location
:
loc %>%
unnest_wider(json) %>%
unnest_longer(results) %>%
unnest_wider(results) %>%
unnest_wider(geometry) %>%
unnest_wider(location)
#> # A tibble: 5 x 11
#> city address_compone⦠formatted_addre⦠bounds lat lng location_type
#> <chr> <list> <chr> <list> <dbl> <dbl> <chr>
#> 1 Hous⦠<list [4]> Houston, TX, USA <name⦠29.8 -95.4 APPROXIMATE
#> 2 LA <list [4]> Los Angeles, CA⦠<name⦠34.1 -118. APPROXIMATE
#> 3 New ⦠<list [3]> New York, NY, U⦠<name⦠40.7 -74.0 APPROXIMATE
#> 4 Chic⦠<list [4]> Chicago, IL, USA <name⦠41.9 -87.6 APPROXIMATE
#> 5 Spri⦠<list [5]> Springfield, MO⦠<name⦠37.2 -93.3 APPROXIMATE
#> # β¦ with 4 more variables: viewport <list>, place_id <chr>, types <list>,
#> # status <chr>
ΠΠΏΡΡΡ ΠΆΠ΅, unnest_auto()
ΡΠΏΡΠΎΡΠ°Π΅Ρ ΠΎΠΏΠΈΡΠ°Π½Π½ΡΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΈΡ Ρ Π½Π΅ΠΊΠΎΡΠΎΡΡΠΌΠΈ ΡΠΈΡΠΊΠ°ΠΌΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΌΠΎΠ³ΡΡ Π±ΡΡΡ Π²ΡΠ·Π²Π°Π½Ρ ΠΈΠ·ΠΌΠ΅Π½Π΅Π½ΠΈΠ΅ΠΌ ΡΡΡΡΠΊΡΡΡΡ Π²Ρ
ΠΎΠ΄ΡΡΠΈΡ
Π΄Π°Π½Π½ΡΡ
:
loc %>%
unnest_auto(json) %>%
unnest_auto(results) %>%
unnest_auto(results) %>%
unnest_auto(geometry) %>%
unnest_auto(location)
#> Using `unnest_wider(json)`; elements have 2 names in common
#> Using `unnest_longer(results)`; no element has names
#> Using `unnest_wider(results)`; elements have 5 names in common
#> Using `unnest_wider(geometry)`; elements have 4 names in common
#> Using `unnest_wider(location)`; elements have 2 names in common
#> # A tibble: 5 x 11
#> city address_compone⦠formatted_addre⦠bounds lat lng location_type
#> <chr> <list> <chr> <list> <dbl> <dbl> <chr>
#> 1 Hous⦠<list [4]> Houston, TX, USA <name⦠29.8 -95.4 APPROXIMATE
#> 2 LA <list [4]> Los Angeles, CA⦠<name⦠34.1 -118. APPROXIMATE
#> 3 New ⦠<list [3]> New York, NY, U⦠<name⦠40.7 -74.0 APPROXIMATE
#> 4 Chic⦠<list [4]> Chicago, IL, USA <name⦠41.9 -87.6 APPROXIMATE
#> 5 Spri⦠<list [5]> Springfield, MO⦠<name⦠37.2 -93.3 APPROXIMATE
#> # β¦ with 4 more variables: viewport <list>, place_id <chr>, types <list>,
#> # status <chr>
ΠΡ ΡΠ°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ΅ΠΌ ΠΏΡΠΎΡΡΠΎ ΠΏΠΎΡΠΌΠΎΡΡΠ΅ΡΡ Π½Π° ΠΏΠ΅ΡΠ²ΡΠΉ Π°Π΄ΡΠ΅Ρ Π΄Π»Ρ ΠΊΠ°ΠΆΠ΄ΠΎΠ³ΠΎ Π³ΠΎΡΠΎΠ΄Π°:
loc %>%
unnest_wider(json) %>%
hoist(results, first_result = 1) %>%
unnest_wider(first_result) %>%
unnest_wider(geometry) %>%
unnest_wider(location)
#> # A tibble: 5 x 11
#> city address_compone⦠formatted_addre⦠bounds lat lng location_type
#> <chr> <list> <chr> <list> <dbl> <dbl> <chr>
#> 1 Hous⦠<list [4]> Houston, TX, USA <name⦠29.8 -95.4 APPROXIMATE
#> 2 LA <list [4]> Los Angeles, CA⦠<name⦠34.1 -118. APPROXIMATE
#> 3 New ⦠<list [3]> New York, NY, U⦠<name⦠40.7 -74.0 APPROXIMATE
#> 4 Chic⦠<list [4]> Chicago, IL, USA <name⦠41.9 -87.6 APPROXIMATE
#> 5 Spri⦠<list [5]> Springfield, MO⦠<name⦠37.2 -93.3 APPROXIMATE
#> # β¦ with 4 more variables: viewport <list>, place_id <chr>, types <list>,
#> # status <chr>
ΠΠ»ΠΈ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ hoist()
Π΄Π»Ρ ΠΌΠ½ΠΎΠ³ΠΎΡΡΠΎΠ²Π½Π΅Π²ΠΎΠ³ΠΎ ΠΏΠΎΠ³ΡΡΠΆΠ΅Π½ΠΈΡ, ΡΡΠΎΠ±Ρ ΠΏΠ΅ΡΠ΅ΠΉΡΠΈ Π½Π΅ΠΏΠΎΡΡΠ΅Π΄ΡΡΠ²Π΅Π½Π½ΠΎ ΠΊ lat
ΠΈ lng
.
loc %>%
hoist(json,
lat = list("results", 1, "geometry", "location", "lat"),
lng = list("results", 1, "geometry", "location", "lng")
)
#> # A tibble: 5 x 4
#> city lat lng json
#> <chr> <dbl> <dbl> <list>
#> 1 Houston 29.8 -95.4 <named list [2]>
#> 2 LA 34.1 -118. <named list [2]>
#> 3 New York 40.7 -74.0 <named list [2]>
#> 4 Chicago 41.9 -87.6 <named list [2]>
#> 5 Springfield 37.2 -93.3 <named list [2]>
ΠΠΈΡΠΊΠΎΠ³ΡΠ°ΡΠΈΡ Π¨Π°ΡΠ»Ρ ΠΠ΅Π»ΡΡΠ°Π½Π΄
Π Π·Π°Π²Π΅ΡΡΠ΅Π½ΠΈΠΈ ΠΌΡ ΡΠ°ΡΡΠΌΠΎΡΡΠΈΠΌ ΡΠ°ΠΌΡΡ ΡΠ»ΠΎΠΆΠ½ΡΡ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΈΡ β Π΄ΠΈΡΠΊΠΎΠ³ΡΠ°ΡΠΈΡ Π¨Π°ΡΠ»Ρ ΠΠ΅Π»ΡΡΠ°Π½Π΄. ΠΠ°ΠΊ ΠΈ Π² ΠΏΡΠΈΠ²Π΅Π΄ΡΠ½Π½ΡΡ
Π²ΡΡΠ΅ ΠΏΡΠΈΠΌΠ΅ΡΠ°Ρ
, ΠΌΡ Π½Π°ΡΠΈΠ½Π°Π΅ΠΌ Ρ ΠΊΠΎΠ½Π²Π΅ΡΡΠ°ΡΠΈΠΈ ΡΠΏΠΈΡΠΊΠ° Π² Π΄Π°ΡΠ° ΡΡΠ΅ΠΉΠΌ Ρ ΠΎΠ΄Π½ΠΈΠΌ ΡΡΠΎΠ»Π±ΡΠΎΠΌ, Π° Π·Π°ΡΠ΅ΠΌ ΡΠ°ΡΡΠΈΡΠΈΠΌ Π΅Π³ΠΎ, ΡΡΠΎΠ±Ρ ΠΊΠ°ΠΆΠ΄ΡΠΉ ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ Π±ΡΠ» ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΠΌ ΡΡΠΎΠ»Π±ΡΠΎΠΌ. Π’Π°ΠΊΠΆΠ΅ Ρ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΡΡ ΡΡΠΎΠ»Π±Π΅Ρ date_added
Π² ΡΠΎΠΎΡΠ²Π΅ΡΡΡΠ²ΡΡΡΠΈΠΉ ΡΠΎΡΠΌΠ°Ρ Π΄Π°ΡΡ ΠΈ Π²ΡΠ΅ΠΌΠ΅Π½ΠΈ Π² R.
discs <- tibble(disc = discog) %>%
unnest_wider(disc) %>%
mutate(date_added = as.POSIXct(strptime(date_added, "%Y-%m-%dT%H:%M:%S")))
discs
#> # A tibble: 155 x 5
#> instance_id date_added basic_information id rating
#> <int> <dttm> <list> <int> <int>
#> 1 354823933 2019-02-16 17:48:59 <named list [11]> 7496378 0
#> 2 354092601 2019-02-13 14:13:11 <named list [11]> 4490852 0
#> 3 354091476 2019-02-13 14:07:23 <named list [11]> 9827276 0
#> 4 351244906 2019-02-02 11:39:58 <named list [11]> 9769203 0
#> 5 351244801 2019-02-02 11:39:37 <named list [11]> 7237138 0
#> 6 351052065 2019-02-01 20:40:53 <named list [11]> 13117042 0
#> 7 350315345 2019-01-29 15:48:37 <named list [11]> 7113575 0
#> 8 350315103 2019-01-29 15:47:22 <named list [11]> 10540713 0
#> 9 350314507 2019-01-29 15:44:08 <named list [11]> 11260950 0
#> 10 350314047 2019-01-29 15:41:35 <named list [11]> 11726853 0
#> # β¦ with 145 more rows
ΠΠ° ΡΡΠΎΠΌ ΡΡΠΎΠ²Π½Π΅ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠ»ΠΈ ΠΈΠ½ΡΠΎΡΠΌΠ°ΡΠΈΡ ΠΎ ΡΠΎΠΌ, ΠΊΠΎΠ³Π΄Π° ΠΊΠ°ΠΆΠ΄ΡΠΉ Π΄ΠΈΡΠΊ Π±ΡΠ» Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ Π² Π΄ΠΈΡΠΊΠΎΠ³ΡΠ°ΡΠΈΡ Π¨Π°ΡΠ»Ρ, Π½ΠΎ ΠΏΡΠΈ ΡΡΠΎΠΌ Π½Π΅ Π²ΠΈΠ΄ΠΈΠΌ Π½ΠΈΠΊΠ°ΠΊΠΈΡ
Π΄Π°Π½Π½ΡΡ
ΠΎΠ± ΡΡΠΈΡ
Π΄ΠΈΡΠΊΠ°Ρ
. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π½Π°ΠΌ Π½ΡΠΆΠ½ΠΎ ΡΠ°ΡΡΠΈΡΠΈΡΡ ΡΡΠΎΠ»Π±Π΅Ρ basic_information
:
discs %>% unnest_wider(basic_information)
#> Column name `id` must not be duplicated.
#> Use .name_repair to specify repair.
Π ΡΠΎΠΆΠ°Π»Π΅Π½ΠΈΡ ΠΌΡ ΠΏΠΎΠ»ΡΡΠΈΠΌ ΠΎΡΠΈΠ±ΠΊΡ, Ρ.ΠΊ. Π²Π½ΡΡΡΠΈ ΡΠΏΠΈΡΠΊΠ° basic_information
Π΅ΡΡΡ ΠΎΠ΄Π½ΠΎΠΈΠΌΡΠ½Π½ΡΠΉ ΡΡΠΎΠ»Π±Π΅Ρ basic_information
. ΠΡΠΈ Π²ΠΎΠ·Π½ΠΈΠΊΠ½ΠΎΠ²Π΅Π½ΠΈΠΈ ΠΏΠΎΠ΄ΠΎΠ±Π½ΠΎΠΉ ΠΎΡΠΈΠ±ΠΊΠΈ, Π΄Π»Ρ ΡΠΎΠ³ΠΎ, ΡΡΠΎ Π±Ρ Π±ΡΡΡΡΠΎ ΠΎΠΏΡΠ΅Π΄Π΅Π»ΠΈΡΡ Π΅Ρ ΠΏΡΠΈΡΠΈΠ½Ρ ΠΌΠΎΠΆΠ½ΠΎ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ names_repair = "unique"
:
discs %>% unnest_wider(basic_information, names_repair = "unique")
#> New names:
#> * id -> id...6
#> * id -> id...14
#> # A tibble: 155 x 15
#> instance_id date_added labels year artists id...6 thumb title
#> <int> <dttm> <list> <int> <list> <int> <chr> <chr>
#> 1 354823933 2019-02-16 17:48:59 <list⦠2015 <list ⦠7.50e6 http⦠Demo
#> 2 354092601 2019-02-13 14:13:11 <listβ¦ 2013 <list β¦ 4.49e6 httpβ¦ Obseβ¦
#> 3 354091476 2019-02-13 14:07:23 <list⦠2017 <list ⦠9.83e6 http⦠I
#> 4 351244906 2019-02-02 11:39:58 <listβ¦ 2017 <list β¦ 9.77e6 httpβ¦ OΓdoβ¦
#> 5 351244801 2019-02-02 11:39:37 <listβ¦ 2015 <list β¦ 7.24e6 httpβ¦ A Caβ¦
#> 6 351052065 2019-02-01 20:40:53 <listβ¦ 2019 <list β¦ 1.31e7 httpβ¦ Tashβ¦
#> 7 350315345 2019-01-29 15:48:37 <list⦠2014 <list ⦠7.11e6 http⦠Demo
#> 8 350315103 2019-01-29 15:47:22 <listβ¦ 2015 <list β¦ 1.05e7 httpβ¦ Let β¦
#> 9 350314507 2019-01-29 15:44:08 <listβ¦ 2017 <list β¦ 1.13e7 "" Sub β¦
#> 10 350314047 2019-01-29 15:41:35 <list⦠2017 <list ⦠1.17e7 http⦠Demo
#> # β¦ with 145 more rows, and 7 more variables: formats <list>,
#> # cover_image <chr>, resource_url <chr>, master_id <int>,
#> # master_url <chr>, id...14 <int>, rating <int>
ΠΡΠΎΠ±Π»Π΅ΠΌΠ° Π² ΡΠΎΠΌ, ΡΡΠΎ basic_information
ΠΏΠΎΠ²ΡΠΎΡΡΠ΅Ρ ΡΡΠΎΠ»Π±Π΅Ρ id ΠΊΠΎΡΠΎΡΡΠΉ ΡΠ°ΠΊΠΆΠ΅ Ρ
ΡΠ°Π½ΠΈΡΡΡ Π½Π° Π²Π΅ΡΡ
Π½Π΅ΠΌ ΡΡΠΎΠ²Π½Π΅, ΠΏΠΎΡΡΠΎΠΌΡ ΠΌΡ ΠΌΠΎΠΆΠ΅ΠΌ ΠΏΡΠΎΡΡΠΎ ΡΠ΄Π°Π»ΠΈΡΡ Π΅Π³ΠΎ:
discs %>%
select(-id) %>%
unnest_wider(basic_information)
#> # A tibble: 155 x 14
#> instance_id date_added labels year artists id thumb title
#> <int> <dttm> <list> <int> <list> <int> <chr> <chr>
#> 1 354823933 2019-02-16 17:48:59 <list⦠2015 <list ⦠7.50e6 http⦠Demo
#> 2 354092601 2019-02-13 14:13:11 <listβ¦ 2013 <list β¦ 4.49e6 httpβ¦ Obseβ¦
#> 3 354091476 2019-02-13 14:07:23 <list⦠2017 <list ⦠9.83e6 http⦠I
#> 4 351244906 2019-02-02 11:39:58 <listβ¦ 2017 <list β¦ 9.77e6 httpβ¦ OΓdoβ¦
#> 5 351244801 2019-02-02 11:39:37 <listβ¦ 2015 <list β¦ 7.24e6 httpβ¦ A Caβ¦
#> 6 351052065 2019-02-01 20:40:53 <listβ¦ 2019 <list β¦ 1.31e7 httpβ¦ Tashβ¦
#> 7 350315345 2019-01-29 15:48:37 <list⦠2014 <list ⦠7.11e6 http⦠Demo
#> 8 350315103 2019-01-29 15:47:22 <listβ¦ 2015 <list β¦ 1.05e7 httpβ¦ Let β¦
#> 9 350314507 2019-01-29 15:44:08 <listβ¦ 2017 <list β¦ 1.13e7 "" Sub β¦
#> 10 350314047 2019-01-29 15:41:35 <list⦠2017 <list ⦠1.17e7 http⦠Demo
#> # β¦ with 145 more rows, and 6 more variables: formats <list>,
#> # cover_image <chr>, resource_url <chr>, master_id <int>,
#> # master_url <chr>, rating <int>
Π ΠΊΠ°ΡΠ΅ΡΡΠ²Π΅ Π°Π»ΡΡΠ΅ΡΠ½Π°ΡΠΈΠ²Ρ, ΠΌΡ ΠΌΠΎΠ³Π»ΠΈ Π±Ρ ΠΈΡΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΡ hoist()
:
discs %>%
hoist(basic_information,
title = "title",
year = "year",
label = list("labels", 1, "name"),
artist = list("artists", 1, "name")
)
#> # A tibble: 155 x 9
#> instance_id date_added title year label artist
#> <int> <dttm> <chr> <int> <chr> <chr>
#> 1 354823933 2019-02-16 17:48:59 Demo 2015 Tobi⦠Mollot
#> 2 354092601 2019-02-13 14:13:11 Obseβ¦ 2013 La Vβ¦ Una Bβ¦
#> 3 354091476 2019-02-13 14:07:23 I 2017 La Vβ¦ S.H.Iβ¦
#> 4 351244906 2019-02-02 11:39:58 OΓdoβ¦ 2017 La Vβ¦ Rata β¦
#> 5 351244801 2019-02-02 11:39:37 A Caβ¦ 2015 Katoβ¦ Ivy (β¦
#> 6 351052065 2019-02-01 20:40:53 Tash⦠2019 High⦠Tashme
#> 7 350315345 2019-01-29 15:48:37 Demo 2014 Mindβ¦ Desgrβ¦
#> 8 350315103 2019-01-29 15:47:22 Let β¦ 2015 Not β¦ Phantβ¦
#> 9 350314507 2019-01-29 15:44:08 Sub β¦ 2017 Not β¦ Sub Sβ¦
#> 10 350314047 2019-01-29 15:41:35 Demo 2017 Presβ¦ Smallβ¦
#> # β¦ with 145 more rows, and 3 more variables: basic_information <list>,
#> # id <int>, rating <int>
ΠΠ΄Π΅ΡΡ Ρ Π±ΡΡΡΡΠΎ ΠΈΠ·Π²Π»Π΅ΠΊΠ°Ρ ΠΈΠΌΡ ΠΏΠ΅ΡΠ²ΠΎΠ³ΠΎ Π»Π΅ΠΉΠ±Π»Π° ΠΈ ΠΈΡΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»Ρ ΠΏΠΎ ΠΈΠ½Π΄Π΅ΠΊΡΡ, ΠΏΠΎΠ³ΡΡΠ·ΠΈΠ²ΡΠΈΡΡ Π²ΠΎ Π²Π»ΠΎΠΆΠ΅Π½Π½ΡΠΉ ΡΠΏΠΈΡΠΎΠΊ.
ΠΠΎΠ»Π΅Π΅ ΡΠΈΡΡΠ΅ΠΌΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΉ ΠΏΠΎΠ΄Ρ ΠΎΠ΄ Π·Π°ΠΊΠ»ΡΡΠ°Π΅ΡΡΡ Π² ΡΠΎΠ·Π΄Π°Π½ΠΈΠΈ ΠΎΡΠ΄Π΅Π»ΡΠ½ΡΡ ΡΠ°Π±Π»ΠΈΡ Π΄Π»Ρ ΠΈΡΠΏΠΎΠ»Π½ΠΈΡΠ΅Π»Ρ ΠΈ Π»Π΅ΠΉΠ±Π»Π°:
discs %>%
hoist(basic_information, artist = "artists") %>%
select(disc_id = id, artist) %>%
unnest_longer(artist) %>%
unnest_wider(artist)
#> # A tibble: 167 x 8
#> disc_id join name anv tracks role resource_url id
#> <int> <chr> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 7496378 "" Mollot "" "" "" https://api.discog⦠4.62e6
#> 2 4490852 "" Una Bèstia⦠"" "" "" https://api.discog⦠3.19e6
#> 3 9827276 "" S.H.I.T. (⦠"" "" "" https://api.discog⦠2.77e6
#> 4 9769203 "" Rata Negra "" "" "" https://api.discog⦠4.28e6
#> 5 7237138 "" Ivy (18) "" "" "" https://api.discog⦠3.60e6
#> 6 13117042 "" Tashme "" "" "" https://api.discog⦠5.21e6
#> 7 7113575 "" Desgraciad⦠"" "" "" https://api.discog⦠4.45e6
#> 8 10540713 "" Phantom He⦠"" "" "" https://api.discog⦠4.27e6
#> 9 11260950 "" Sub Space ⦠"" "" "" https://api.discog⦠5.69e6
#> 10 11726853 "" Small Man ⦠"" "" "" https://api.discog⦠6.37e6
#> # β¦ with 157 more rows
discs %>%
hoist(basic_information, format = "formats") %>%
select(disc_id = id, format) %>%
unnest_longer(format) %>%
unnest_wider(format) %>%
unnest_longer(descriptions)
#> # A tibble: 280 x 5
#> disc_id descriptions text name qty
#> <int> <chr> <chr> <chr> <chr>
#> 1 7496378 Numbered Black Cassette 1
#> 2 4490852 LP <NA> Vinyl 1
#> 3 9827276 "7"" <NA> Vinyl 1
#> 4 9827276 45 RPM <NA> Vinyl 1
#> 5 9827276 EP <NA> Vinyl 1
#> 6 9769203 LP <NA> Vinyl 1
#> 7 9769203 Album <NA> Vinyl 1
#> 8 7237138 "7"" <NA> Vinyl 1
#> 9 7237138 45 RPM <NA> Vinyl 1
#> 10 13117042 "7"" <NA> Vinyl 1
#> # β¦ with 270 more rows
ΠΠ°ΡΠ΅ΠΌ Π²Ρ ΠΌΠΎΠΆΠ΅ΡΠ΅ ΠΏΡΠΈΡΠΎΠ΅Π΄ΠΈΠ½ΠΈΡΡ ΠΈΡ ΠΎΠ±ΡΠ°ΡΠ½ΠΎ ΠΊ ΠΈΡΡ ΠΎΠ΄Π½ΠΎΠΌΡ Π½Π°Π±ΠΎΡΡ Π΄Π°Π½Π½ΡΡ ΠΏΠΎ ΠΌΠ΅ΡΠ΅ Π½Π΅ΠΎΠ±Ρ ΠΎΠ΄ΠΈΠΌΠΎΡΡΠΈ.
ΠΠ°ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅
Π ΡΠ΄ΡΠΎ Π±ΠΈΠ±Π»ΠΈΠΎΡΠ΅ΠΊΠΈ tidyverse
Π²Ρ
ΠΎΠ΄ΡΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ ΠΏΠΎΠ»Π΅Π·Π½ΡΡ
ΠΏΠ°ΠΊΠ΅ΡΠΎΠ² ΠΎΠ±ΡΠ΅Π΄ΠΈΠ½ΡΠ½Π½ΡΠ΅ ΠΎΠ±ΡΠ΅ΠΉ ΡΠΈΠ»ΠΎΡΠΎΡΠΈΠ΅ΠΉ ΠΎΠ±ΡΠ°Π±ΠΎΡΠΊΠΈ Π΄Π°Π½Π½ΡΡ
.
Π ΡΡΠΎΠΉ ΡΡΠ°ΡΡΠ΅ ΠΌΡ ΡΠ°Π·ΠΎΠ±ΡΠ°Π»ΠΈ ΡΠ΅ΠΌΠ΅ΠΉΡΡΠ²ΠΎ ΡΡΠ½ΠΊΡΠΈΠΉ unnest_*()
, ΠΊΠΎΡΠΎΡΡΠ΅ Π½Π°ΠΏΡΠ°Π²Π»Π΅Π½Ρ Π½Π° ΡΠ°Π±ΠΎΡΡ Ρ ΠΈΠ·Π²Π»Π΅ΡΠ΅Π½ΠΈΠ΅ΠΌ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΠΈΠ· Π²Π»ΠΎΠΆΠ΅Π½Π½ΡΡ
ΡΠΏΠΈΡΠΊΠΎΠ². ΠΠ°Π½Π½ΡΠΉ ΠΏΠ°ΠΊΠ΅Ρ ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²ΠΎ Π΄ΡΡΠ³ΠΈΡ
ΠΏΠΎΠ»Π΅Π·Π½ΡΡ
ΡΡΠ½ΠΊΡΠΈΠΉ, ΠΊΠΎΡΠΎΡΡΠ΅ ΡΠΏΡΠΎΡΠ°ΡΡ ΠΏΡΠ΅ΠΎΠ±ΡΠ°Π·ΠΎΠ²Π°Π½ΠΈΠ΅ Π΄Π°Π½Π½ΡΡ
ΡΠΎΠ³Π»Π°ΡΠ½ΠΎ ΠΊΠΎΠ½ΡΠ΅ΠΏΡΠΈΠΈ Tidy Data.
ΠΡΡΠΎΡΠ½ΠΈΠΊ: habr.com