tidyr ํจํค์ง ํ์ด๋ณด๊ธฐ
tidyr์ tidy data๋ฅผ ํ์ฑํ๊ธฐ ์ํด ๊ณ ์๋ ํจํค์ง์
๋๋ค. tidy data์์ 1) ์ด์ ๋ณ์๋ฅผ ์๋ฏธํ๊ณ , 2) ํ์ ํ๋์ ์ผ์ด์ค๋ฅผ ์๋ฏธํ๋ฉฐ, 3) ํ๋์ ์
์ ํ๋์ ๊ฐ์ ์๋ฏธํฉ๋๋ค.
๋ชฉ์ฐจ
nest
nest
์์๋ฅผ ํตํด, ๋จ์ํ group_by๋ฅผ ํ๋ ๊ฒ๊ณผ group_by ์ดํ nest๋ฅผ ํ ํ์ ์ด๋ป๊ฒ ๋ฐ์ดํฐ๊ฐ ์ ๋ฆฌ๋๋์ง ํ์ธํด๋ณด์.
nest ์์
1
2
iris %>%
group_by ( Species )
## # A tibble: 150 x 5
## # Groups: Species [3]
## Sepal.Length Sepal.Width Petal.Length Petal.Width Species
## <dbl> <dbl> <dbl> <dbl> <fct>
## 1 5.1 3.5 1.4 0.2 setosa
## 2 4.9 3 1.4 0.2 setosa
## 3 4.7 3.2 1.3 0.2 setosa
## 4 4.6 3.1 1.5 0.2 setosa
## 5 5 3.6 1.4 0.2 setosa
## 6 5.4 3.9 1.7 0.4 setosa
## 7 4.6 3.4 1.4 0.3 setosa
## 8 5 3.4 1.5 0.2 setosa
## 9 4.4 2.9 1.4 0.2 setosa
## 10 4.9 3.1 1.5 0.1 setosa
## # ... with 140 more rows
1
2
3
iris %>%
group_by ( Species ) %>%
nest ()
## # A tibble: 3 x 2
## # Groups: Species [3]
## Species data
## <fct> <list>
## 1 setosa <tibble [50 x 4]>
## 2 versicolor <tibble [50 x 4]>
## 3 virginica <tibble [50 x 4]>
์ฐธ๊ณ
[1] https://gomguard.tistory.com/229