Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
66th Tokyo.R Beginner session2
Search
kilometer
December 16, 2017
Technology
2
1.1k
66th Tokyo.R Beginner session2
発表資料です。
kilometer
December 16, 2017
Tweet
Share
More Decks by kilometer
See All by kilometer
TokyoR#111_ANOVA
kilometer
2
830
TokyoR109.pdf
kilometer
1
440
TokyoR#108_NestedDataHandling
kilometer
0
750
TokyoR#107_R_GeoData
kilometer
0
390
SappoRo.R_roundrobin
kilometer
0
120
TokyoR#104_DataProcessing
kilometer
1
660
TokyoR#103_DataProcessing
kilometer
0
850
TokyoR#102_RMarkdown
kilometer
1
610
TokyoR#101_RegressionAnalysis
kilometer
0
350
Other Decks in Technology
See All in Technology
なぜ今 AI Agent なのか _近藤憲児
kenjikondobai
4
1.3k
ドメイン名の終活について - JPAAWG 7th -
mikit
33
20k
[FOSS4G 2024 Japan LT] LLMを使ってGISデータ解析を自動化したい!
nssv
1
210
スクラム成熟度セルフチェックツールを作って得た学びとその活用法
coincheck_recruit
1
140
Terraform未経験の御様に対してどの ように導⼊を進めていったか
tkikuchi
2
430
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
7
730
Terraform Stacks入門 #HashiTalks
msato
0
350
VideoMamba: State Space Model for Efficient Video Understanding
chou500
0
190
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
【若手エンジニア応援LT会】ソフトウェアを学んできた私がインフラエンジニアを目指した理由
kazushi_ohata
0
150
20241120_JAWS_東京_ランチタイムLT#17_AWS認定全冠の先へ
tsumita
2
240
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Building Adaptive Systems
keathley
38
2.3k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Faster Mobile Websites
deanohume
305
30k
[RailsConf 2023] Rails as a piece of cake
palkan
52
4.9k
Code Reviewing Like a Champion
maltzj
520
39k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
A designer walks into a library…
pauljervisheath
203
24k
Transcript
66th Tokyo.R @ຊ 初心者セッション2 - データ処理編 - @kilometer
Whoʂʁ 誰だ?
Whoʂʁ ໊લɿ @kilometer ৬ۀɿ ϙευΫ(ֶത࢜) ઐɿ ߦಈηϯαϦϯά ɹ ਆܦΠϝʔδϯά ҩ༻γεςϜֶ
Rྺɿ म࢜ͷࠒ͔Β10͙Β͍ɻ ྲྀߦ:ɹ෩ϋϯόʔά
Tokyo.R 初心者セッション ॳ৺ऀ͕தڃऀʹͳΔͨΊͷٕज़ ΔͱḿΔٕज़ͷجૅ ࣗ༝ʹͳΔͨΊͷಓ۩ͱߟ͑ํ ʹ
ߟ͑Δ ॻ͘ ࣮ߦ͢Δ プログラミング ಡΉ
࣮ߦ͢Δ https://www.amazon.co.jp/dp/B00Y0UI990/
ಓ۩ʢݴޠΛؚΉʣɺࢥߟΛ͢Δɻ ࢥߟɺಓ۩ʢݴޠΛؚΉʣΛ͢Δɻ
ߟ͑Δ ॻ͘ 捗るプログラミング ಡΉ ߴ͍ࣗ༝Ͱ ετϨεͳ͘ γʔϜϨεʹ
自由なデータ処理 in R ύΠϓԋࢉࢠ verbؔ܈
ԋࢉࢠ− ݞ׳Β͠ − ʮRͷԋࢉࢠಛूʯy__mattu https://ymattu.github.io/JapanR2017/slide.html#/ ೖԋࢉࢠ ϒʔϧԋࢉࢠ
ԋࢉࢠ− ݞ׳Β͠ − ೖԋࢉࢠ A <- B A <<- B
# ೖԋࢉࢠ # Ӭଓೖԋࢉࢠ
ԋࢉࢠ− ݞ׳Β͠ − ೖԋࢉࢠ ex_func <- function(){ x <- 600
x <<- 100 ptint(x) } # άϩʔόϧม # ϩʔΧϧม ʮRͷԋࢉࢠಛूʯy__mattu https://ymattu.github.io/JapanR2017/slide.html#/
ԋࢉࢠ− ݞ׳Β͠ − ೖԋࢉࢠ ex_func [1] 600 x [1] 100
ԋࢉࢠ− ݞ׳Β͠ − ೖԋࢉࢠ ex_func [1] 600 x [1] 100
ex_func <- function(){ x <- 600 x <<- 100 ptint(x) }
ԋࢉࢠ− ݞ׳Β͠ − ϒʔϧԋࢉࢠ Boolean Algebra A == B A
!= B A | B A & B A %in% B # equal to # not equal to # or # and # is A in B? https://www.amazon.co.jp/dp/0486600289
ύΠϓԋࢉࢠ X %>% f X %>% f(y) X %>% f
%>% g X %>% f(y, .) f(X) f(X, y) g(f(X)) f(y, X) %>% {magrittr} ʮdplyr࠶ೖʢجຊฤʣʯyutanihilation https://speakerdeck.com/yutannihilation/dplyrzai-ru-men-ji-ben-bian
ύΠϓԋࢉࢠ%>% {magrittr} ʮ࠷ۙύΠϓ͔͠ଧͬͯͳ͍Ͱ͢ʯ ʮύΠϓɺ͋Ε͍͍Αͳͬͯ ɹଞͷݴޠͷਓօΜͳࢥͬͯ·͢Αʯ ʮ1͙Β͍͔͚ͯΏͬ͘Γͬͪ͜ ɹʢύΠϓʣʹγϑτ͠·ͨ͠Ͷʯ ʲதಟ Ѫ༻ऀͨͪͷʳ ʮRίϛϡχςΟ࢛ํࢁʯhttps://rlangradio.org/
ύΠϓԋࢉࢠ%>% {magrittr} dat1 <- f1(dat0, var1) # ͦΕͱ͜͏ॻ͖·͔͢ʁ dat2 <-
f2(dat1, var2) dat3 <- f3(dat2, var3) # ͜͏ॻ͖·͔͢ʁ dat <- f3(f2(f1(dat0, var1), var2), var3)
ύΠϓԋࢉࢠ%>% {magrittr} # ͑ʁ͜͏ॻ͖·͢ʁ dat <- f3(f2(f1(dat0, var1), var2), var3)
ೖޱ ग़ޱ ᶃ ᶄ ᶅ ࢥߟͷྲྀΕ ߏͷରԠ
ύΠϓԋࢉࢠ%>% {magrittr} # ͋ΕΕɺ͜͏ॻ͘ΜͰ͔͢ʁ dat <- f3(f2(f1(dat0, var1), var2), var3)
ೖޱ ग़ޱ ࢥߟͷྲྀΕ ղಡͷྲྀΕ
ύΠϓԋࢉࢠ%>% {magrittr} # ຊʹɺ͜͏ॻ͖·͔͢ʁ dat <- f6(f5(f4(f3(f2(f1(dat0, var1-1, var1-2), var2),
var3), var4-1, var4-2, var4-3), var5), var6) ೖޱ ग़ޱ ࢥߟͷྲྀΕ ߏͷରԠ
ύΠϓԋࢉࢠ%>% {magrittr} # ϚδͰɺ͜͏ॻ͖·͔͢ʁ dat <- f6(f5(f4(f3(f2(f1(dat0, var1-1, var1-2), var2),
var3), var4-1, var4-2, var4-3), var5), var6) ೖޱ ग़ޱ ࢥߟͷྲྀΕ ղಡͷྲྀΕ
ύΠϓԋࢉࢠ%>% {magrittr} # ͜ɺ͜͏ॻ͖·͔͢ʁ dat <- f6(f5(f4(var4-1, f3(f2(f1(dat0, var1-1, var1-2),
var2), var3-2), var4-2, var4-3), var5), var6)
ύΠϓԋࢉࢠ%>% {magrittr} # ͱͳΔͱɺ͜͏ॻ͖·͔͢ʁ ೖޱ ग़ޱ dat1 <- f1(dat0, var1)
dat2 <- f2(dat1, var2) dat3 <- f3(dat2, var3) ᶃ ᶄ ᶅ ೖޱ ग़ޱ ೖޱ ग़ޱ ࢥߟͷྲྀΕ ղಡͷྲྀΕ
ύΠϓԋࢉࢠ%>% {magrittr} # ͏ʔΜɺ͜͏ॻ͖·͔͢ʁ ਅͷೖޱ Ծͷग़ޱ dat1 <- f1(dat0, var1)
dat2 <- f2(dat1, var2) dat3 <- f3(dat2, var3) ᶃ ᶄ ᶅ Ծͷೖޱ Ծͷग़ޱ Ծͷೖޱ ਅͷग़ޱ ࢥߟͷྲྀΕ ղಡͷྲྀΕ
ύΠϓԋࢉࢠ%>% {magrittr} # ͛͛͛ɺ͜͏ॻ͖·͔͢ʁ ਅͷೖޱ dat1 <- f1(dat0, var1-1, var1-2)
dat2 <- f2(dat1, var2) dat3 <- f3(dat2, var3) dat4 <- f4(var4-1, dat3, var4-2) dat5 <- f5(dat4, var5) dat6 <- f6(dat5, var6) ਅͷग़ޱ ࢥߟͷྲྀΕ ղಡͷྲྀΕ
ύΠϓԋࢉࢠ%>% {magrittr} # ύΠϓͷώτͳΒ͜͏ॻ͖·͢ɻ dat0 %>% f1(var1-1, var1-2) %>% f2(var2)
%>% f3(var3) %>% f4(var4-1, ., var4-2) %>% f5(var5) %>% f6(var6) -> dat ೖޱ ग़ޱ
ύΠϓԋࢉࢠ%>% {magrittr} # ͜͏ͬͯॻ͘ࣄͰ͖·͢ɻ dat <- dat0 %>% f1(var1-1, var1-2)
%>% f2(var2) %>% f3(var3) %>% f4(var4-1, ., var4-2) %>% f5(var5) %>% f6(var6) ೖޱ ग़ޱ
ύΠϓԋࢉࢠ%>% {magrittr} # ͜͏ͬͯॻ͘ࣄͰ͖·͢ɻ dat <- dat0 %>% f1(var1-1, var1-2)
%>% f2(var2) %>% f3(var3) %>% f4(var4-1, ., var4-2) %>% f5(var5) %>% f6(var6) ೖޱ ग़ޱ υοτ͕͋Δ
ύΠϓԋࢉࢠ X %>% f X %>% f(y) X %>% f
%>% g X %>% f(y, .) f(X) f(X, y) g(f(X)) f(y, X) %>% {magrittr} ͜Ε
ύΠϓԋࢉࢠ%>% {magrittr} dat <- iris %>% .[, 1:3] %>% prcomp
iris %>% .[, 1:3] %>% prcomp -> dat “डಈଶ”ͬΆ͍ “ೳಈଶ”ͬΆ͍ BA͕F͞Εͨͷ AΛF͢ΔͱBʹͳΔ
ύΠϓԋࢉࢠ%>% {magrittr} library(magrittr) iris %>% str 'data.frame': 150 obs. of
5 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 ... $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 ... $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 ... $ Species : Factor w/ 3 levels "setosa", ... str(iris)
ύΠϓԋࢉࢠ%>% {magrittr} library(magrittr) iris %>% cbind(a = 1:150) %>% str
'data.frame': 150 obs. of 6 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 ... $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7... $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 ... $ Species : Factor w/ 3 levels "setosa", ... $ a : int 1 2 3 4 5 6 7 8 9 10 ...
ύΠϓԋࢉࢠ%>% {magrittr} library(magrittr) iris %>% .[, 1:3] %>% prcomp %>%
str List of 5 $ sdev : num [1:3] 1.921 0.491 0.244 $ rotation: num [1:3, 1:3] 0.39 -0.091 ... ..- attr(*, "dimnames")=List of 2 .. ..$ : chr [1:3] "Sepal.Length" "Sepal.Width" ... .. ..$ : chr [1:3] "PC1" "PC2" "PC3" $ center : Named num [1:3] 5.84 3.06 3.76 ..- attr(*, "names")= chr [1:3] "Sepal.Length" ... $ scale : logi FALSE $ x : num [1:150, 1:3] -2.49 -2.52 -2.71 -2.56 ...
ύΠϓԋࢉࢠ%>% {magrittr} library(magrittr) dat <- iris %>% .[, 1:3] %>%
prcomp %>% .$x %>% data.frame %T>% plot dat <- iris[, 1:3] dat <- prcomp(dat) dat <- dat$x dat <- data.frame(dat) plot(dat) teeԋࢉࢠ ʮ෭࡞༻Λڐ͠ͳ͕Βchain͍ͯ͘͠ʯdichika http://d.hatena.ne.jp/dichika/20140731/p1
ߟ͑Δ ॻ͘ 捗るプログラミング ಡΉ ߴ͍ࣗ༝Ͱ ετϨεͳ͘ Sequentialʹ γʔϜϨεʹ
verbؔ܈ ύΠϓԋࢉࢠ %>% 自由なデータ処理 in R
mutate select filter arrange summaries join # ΧϥϜͷՃ # ΧϥϜͷબ
# ߦͷߜΓࠐΈ # ߦͷฒͼସ͑ # ͷू # ߦྻͷ݁߹ {dplyr} WFSCT WFSCؔ܈
It (dplyr) provides simple “verbs” to help you translate your
thoughts into code. functions that correspond to the most common data manipulation tasks Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html WFSCT {dplyr}
dplyrɺ͋ͳͨͷߟ͑Λίʔυʹ༁ ͢ΔͨΊͷʲಈࢺʳΛఏڙ͢Δɻ σʔλૢ࡞ʹ͓͚ΔجຊͷΩ Λɺɹɹɹγϯϓϧʹ࣮ߦͰ͖Δؔ (܈) Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html WFSCT
{dplyr} ※ ͔ͳΓҙ༁
WFSCT S V O C M ؔ ΦϒδΣΫτ ֤छҾ ͦΕҎ֎ͷએݴ
(ذ, ܁ฦ, etc) ※ ΠϝʔδͰ͢
WFSCT S V O C M ※ ΠϝʔδͰ͢ ಈࢺʴಈࢺʹ͞Εͨम০ޠ {dplyr}ͷverbؔ
WFSCT {dplyr} By constraining your options, it helps you think
about your data manipulation challenges. Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html
WFSCT {dplyr} બࢶΛ制限͢Δ͜ͱͰɺ σʔλղੳͷεςοϓΛ γϯϓϧʹߟ͑ΒΕ·͢Ϥɻ ʢΊͬͪΌҙ༁ʣ Introduction to dplyr https://cran.r-project.org/web/packages/dplyr/vignettes/dplyr.html
※ ·͞ʹҙ༁
ΑΓଟ͘ͷ੍Λ՝͢ࣄͰɺ ࠢͷᐫ͔ΒɺΑΓࣗ༝ʹͳΔɻ Igor Stravinsky И́горь Ф Страви́нский The more constraints
one imposes, the more one frees one's self of the chains that shackle the spirit. 1882 - 1971 ※ ׂͱҙ༁
ߟ͑Δ ॻ͘ 捗るプログラミング ಡΉ ߴ͍ࣗ༝Ͱ ετϨεͳ͘ Sequentialʹ γʔϜϨεʹ
mutate select filter arrange summaries join # ΧϥϜͷՃ # ΧϥϜͷબ
# ߦͷߜΓࠐΈ # ߦͷฒͼସ͑ # ͷू # ߦྻͷ݁߹ {dplyr} WFSCT WFSCؔ܈
֬ೝ ΧϥϜ ʢvariablesʣ ߦ ʢobservationsʣ
mutate select filter arrange summaries join # ΧϥϜͷՃ # ΧϥϜͷબ
# ߦͷߜΓࠐΈ # ߦͷฒͼସ͑ # ͷू # ߦྻͷ݁߹ {dplyr} WFSCT WFSCؔ܈
WFSCT {dplyr} mutate # ΧϥϜͷՃ + mutate
library(dplyr) iris %>% mutate(a = 1:nrow(.)) %>% str 'data.frame': 150
obs. of 6 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 ... $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7... $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 ... $ Species : Factor w/ 3 levels "setosa", ... $ a : int 1 2 3 4 5 6 7 8 9 10 ... WFSCT {dplyr}
library(dplyr) iris %>% mutate(a = 1:nrow(.), a = a *
5/3 %>% round) 'data.frame': 150 obs. of 6 variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 ... $ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7... $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 ... $ Species : Factor w/ 3 levels “setosa”, ... $ a : num 1.67 3.33 5 6.67 8.33 ... ... WFSCT {dplyr} ্ॻ͖͞ΕΔ
WFSCT {dplyr} select # ΧϥϜͷબ select
library(dplyr) iris %>% select(Sepal.Length, Sepal.Width) 'data.frame': 150 obs. of 6
variables: $ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 ... $ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 ... WFSCT {dplyr}
library(dplyr) iris %>% select(contains(“Width”)) 'data.frame': 150 obs. of 6 variables:
$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 ... $ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 ... WFSCT {dplyr} Select helpؔ
WFSCT {dplyr} # Select helpؔ܈ starts_with("s") ends_with("s") contains("se") matches("^.e") one_of(c("Sepal.Length",
"Species")) everything() https://kazutan.github.io/blog/2017/04/dplyr-select-memo/ ʮdplyr::selectͷ׆༻ྫϝϞʯkazutan
mutate select filter arrange summaries join # ΧϥϜͷՃ # ΧϥϜͷબ
# ߦͷߜΓࠐΈ # ߦͷฒͼସ͑ # ͷू # ߦྻͷ݁߹ {dplyr} WFSCT WFSCؔ܈
WFSCT {dplyr} filter # ߦͷߜΓࠐΈ filter
library(dplyr) iris %>% filter(Species == "versicolor") WFSCT {dplyr} 'data.frame': 50
obs. of 5 variables: $ Sepal.Length: num 7 6.4 6.9 5.5 6.5 5.7 6.3 ... $ Sepal.Width : num 3.2 3.2 3.1 2.3 2.8 2.8 ... $ Petal.Length: num 4.7 4.5 4.9 4 4.6 4.5 4.7 ... $ Petal.Width : num 1.4 1.5 1.5 1.3 1.5 1.3 ... $ Species : Factor w/ 3 levels "setosa","versicolor",..: 2 2 2 2 2 2 2 2 2 2 ...
library(dplyr) iris %>% filter(Species == "versicolor") WFSCT {dplyr} NSE (Non-Standard
Evaluation) 'data.frame': 50 obs. of 5 variables: $ Sepal.Length: num 7 6.4 6.9 5.5 6.5 5.7 6.3 ... $ Sepal.Width : num 3.2 3.2 3.1 2.3 2.8 2.8 ... $ Petal.Length: num 4.7 4.5 4.9 4 4.6 4.5 4.7 ... $ Petal.Width : num 1.4 1.5 1.5 1.3 1.5 1.3 ... $ Species : Factor w/ 3 levels "setosa","versicolor",..: 2 2 2 2 2 2 2 2 2 2 ...
filter(df, x == "a", y == 1) /4&ͷ NSE (Non-Standard
Evaluation) df[df$x == "a" & df$y == 1, ] SE (Standard Evaluation) http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr
filter(df, x == "a", y == 1) /4&ͷ NSEΛ͏ͱɺ ɾdfͷ໊લΛԿճॻ͔ͳ͍͍ͯ͘Αɻ
ɾSQLʹ༁͢Δ࣌ʹָͩΑɻ http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr df[df$x == "a" & df$y == 1, ]
filter(df, x == "a", y == 1) /4&ͷ NSEΛ͏ͱɺ ɾdfͷ໊લΛԿճॻ͔ͳ͍͍ͯ͘Αɻ
ɾSQLʹ༁͢Δ࣌ʹָͩΑɻ ɹɹ http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr ৭ʑ͋Δ͚ͲεοΩϦ͍ͯ͠Δͷਖ਼ٛ (ࢲݟ) df[df$x == "a" & df$y == 1, ]
filter(df, x == "a", y == 1) /4&ͷ NSEΛ͏ͱɺ df[df$x
== "a" & df$y == 1, ] http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr ৭ʑ͋Δ͚ͲεοΩϦ͍ͯ͠Δͷਖ਼ٛ (ࢲݟ) ॻ͖͘͢ɺಡΈ͘͢ɻ ࢥߟͱ࣮ͷڑΛۙ͘ɻ # ಈࢺత # ໊ࢺత
df <- data.frame(x = 1:3, y = 1:3) filter(df, x
== 1) /4&ͷ NSEΛ࠾༻͍ͯ͠ΔͷͰɺ http://dplyr.tidyverse.org/articles/programming.html Programming with dplyr my_var <- "x" filter(df, my_var == 1) ͜Εɹ͕ಈ͔ͳ͍ɻ dfͷmy_varΧϥϜΛ୳͠ʹߦ͘
/4&ͷ my_var <- quo(x) filter(df, (!! my_var) == 1) Ͳʙʙʙͯ͠Γ͚ͨΕɺ
Կނ͜͏ͳΔ͔ɺ ɹʮdplyr࠶ೖʢTidyvalฤʣʯΛࢀরɻ https://speakerdeck.com/yutannihilation/dplyrzai-ru-men-tidyevalbian ʮdplyr࠶ೖʢTidyvalฤʣʯyutanihilation
/4&ͷ my_var <- quo(x) filter(df, (!! my_var) == 1) Ͳʙʙʙͯ͠Γ͚ͨΕɺ
Կނ͜͏ͳΔ͔ɺ ɹʮdplyr࠶ೖʢTidyvalฤʣʯΛࢀরɻ https://speakerdeck.com/yutannihilation/dplyrzai-ru-men-tidyevalbian Մಡੑ্͕͕ΔʁԼ͕Δʁ ͦΕɺ͋ͳͨͱಡΈख࣍ୈɻ ʮdplyr࠶ೖʢTidyvalฤʣʯyutanihilation
mutate select filter arrange summaries join # ΧϥϜͷՃ # ΧϥϜͷબ
# ߦͷߜΓࠐΈ # ߦͷฒͼସ͑ # ͷू # ߦྻͷ݁߹ {dplyr} WFSCT WFSCؔ܈
WFSCT {dplyr} join # ߦྻͷ݁߹ xxx_join関数群 left_join, right_join inner_join, semi_join
full_join anti_join
a <- data.frame(x1 = c(1,2,3), x2 = 10:12) b <-
data.frame(x1 = c(1,3,5), x3 = 100:102) WFSCT {dplyr} > left_join(a, b) > right_join(a, b) x1 x2 x3 1 10 100 2 11 NA 3 12 101 x1 x2 x3 1 10 100 3 12 101 5 NA 102 join # ߦྻͷ݁߹
WFSCT {dplyr} > inner_join(a, b) > semi_join(a, b) x1 x2
x3 1 10 100 3 12 101 x1 x2 1 10 3 12 join # ߦྻͷ݁߹ a <- data.frame(x1 = c(1,2,3), x2 = 10:12) b <- data.frame(x1 = c(1,3,5), x3 = 100:102)
WFSCT {dplyr} > anti_join(a, b) x1 x2 2 11 join
# ߦྻͷ݁߹ a <- data.frame(x1 = c(1,2,3), x2 = 10:12) b <- data.frame(x1 = c(1,3,5), x3 = 100:102) > full_join(a, b) x1 x2 x3 1 10 100 2 11 NA 3 12 101 5 NA 102
WFSCT {dplyr} https://twitter.com/yutannihilation/status/551572539697143808 join # ߦྻͷ݁߹
ύΠϓԋࢉࢠ %>% verbؔ܈ mutate, select, filter, arrange, summaries, join 自由なデータ処理
in R
https://www.tidyverse.org/
ߟ͑Δ ॻ͘ 捗るプログラミング ಡΉ ߴ͍ࣗ༝Ͱ ετϨεͳ͘ Sequentialʹ γʔϜϨεʹ
None