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
Tokoy.R #99 パーマーステーションのペンギンたち #1 palmerpenguins
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
bob3bob3
June 03, 2022
Science
1.8k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Tokoy.R #99 パーマーステーションのペンギンたち #1 palmerpenguins
Rのpalmerpenguinsパッケージの紹介。
https://allisonhorst.github.io/palmerpenguins/
bob3bob3
June 03, 2022
More Decks by bob3bob3
See All by bob3bob3
RとLLMで自然言語処理
bob3bob3
3
950
RでPSM分析
bob3bob3
1
450
Rでコンジョイント分析 2024年版
bob3bob3
0
2.5k
『改訂新版前処理大全』の話と Apache Parquet の話 #TokyoR
bob3bob3
0
1.5k
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
660
『データ可視化学入門』をPythonからRに翻訳した話(増強版)
bob3bob3
0
600
『データ可視化学入門』を PythonからRに翻訳した話
bob3bob3
1
670
qeMLパッケージの紹介
bob3bob3
0
2.8k
「国と音楽」 ~spotifyrを用いて~ #muana
bob3bob3
2
670
Other Decks in Science
See All in Science
Kritische evaluatie van GenAI-output voor literatuuronderzoek
voginip
0
180
Bear-safety-running
akirun_run
0
170
HDC tutorial
michielstock
2
730
生成AI・プレプリント時代における 研究成果公開の再設計 ― トップカンファレンス文化はどこへ向かうのか / Redesigning the Dissemination of Research Outputs in the Age of Generative AI and Preprints — Where Is the Top-Conference Culture Heading?
ykiyota
0
28k
データベース10: 拡張実体関連モデル
trycycle
PRO
0
1.2k
Amusing Abliteration
ianozsvald
1
220
J-STAGE全文XML登載必須化について
xspa2012
0
980
Rashomon at the Sound: Reconstructing all possible paleoearthquake histories in the Puget Lowland through topological search
cossatot
0
1.1k
MATSUO Makiko
genomethica
0
160
20260410_SystemsThinking
takusamar
1
110
AI(人工知能)の過去・現在・未来 ~AIは人類を越えるのか~
tagtag
PRO
0
110
20251212_LT忘年会_データサイエンス枠_新川.pdf
shinpsan
0
300
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.9k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
790
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
170
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
340
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
180
BBQ
matthewcrist
89
10k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
Fireside Chat
paigeccino
42
4k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
230
Transcript
パーマーステーションの ペンギンたち #1 Tokyo.R #99 (2022/06/04) @bob3bob3 Artwork by @allison_horst
パーマーステーションのペンギンたち Rには様々なサンプルデータセットが用 意されているのもいいところ。 その中でもpalmerpenguinsパッケージの データセットが練習用、学習用にちょう ど良いので紹介したいというお話。 とりあえず、いますぐ install.packages("palmerpenguins") しましょう! Artwork
by @allison_horst
どう良いの? • ペンギンがかわいい。 • 整形済みのデータと整形前のデータの両方がある。 • 名義尺度と連続尺度の両方の変数が含まれる。 • 名義尺度の変数が複数含まれる。 •
連続尺度の変数も複数含まれる。 • 欠測値(NA)が含まれる。 • 日時の変数が含まれる。 • ペンギンがカワイイ。
palmerpenguinsパッケージ 南極にある米国の越冬基地パーマー基地において Kristen Gorman 博士が行ったペン ギンの生態調査のデータセットです。 引用元 引用元
引用元
引用元
トージャーセン島 引用元 Cynthia Spence (CC BY-NC-ND 4.0) トージャーセン島から眺めるパーマー基地 Cynthia Spence
(CC BY-NC-ND 4.0)
引用元
引用元 IMDb パーマー基地が舞台となる日本映画
どんなデータ? • 2007年、2008年、2009年の3回の調査(越冬隊?)。 • ビスコー諸島、ドリーム島、トージャーセン島の3か所。 • アデリーペンギン、ヒゲペンギン、ジェンツーペンギンの3種のペンギン。 • 嘴の長さ、高さ、翼の長さ、体重、性別、血液検査の結果などが含まれる。 アデリー(Adelie)
ジェンツー(Gentoo) ヒゲ(Chinstrap) Stan Shebs (CC BY-SA 3.0) Andrew Shiva(CC BY-SA 4.0) Stan Shebs (CC BY-SA 3.0)
アデリーペンギン Wikipediaより引用 • くちばしの根元から先端近くまで羽毛でおおわ れているのも特徴で、くちばしが短いように見え るが、口を開けると目の前まで開く。これは南極 の厳しい寒さに適応した結果羽毛が無い部分が 少なくなったと考えられる。
• また、他のペンギンに比べて尾羽が長いが、こ れはヒゲペンギン、ジェンツーペンギンにも共通 する特徴である。ペンギンの分類ではこの3種類 をまとめてアデリーペンギン属(Pygoscelis属)と して扱う。 • Suicaのペンギンのモデル。 Jerzy Strzelecki(CC BY 3.0)
ヒゲペンギン Wikipediaより引用 • 目の後ろから喉を通る黒い帯模様が あるのが特徴である。和名の「ヒゲペ ンギン」は喉を通る帯模様をあごひげ に見立てたものである。また、英名 の"Chinstrap"は帽子やヘルメットの あごひものことで、これもやはり喉を 通る帯模様に由来している。
引用元
ジェンツーペンギン Wikipediaより引用 • 両目をつなぐ白い帯模様が特徴であ る。 • 大きさはペンギン18種類のうち、コウ テイペンギン、キングペンギンに次い で3番目に大きい。また、オスの方がメ スよりわずかに大きい。更に、ペンギ
ンで最も泳ぐのが速いペンギンでもあ る。最高時速は時速35kmにも達す る。 Ben Tubby(CC BY 2.0)
2つのデータセット penguins_raw 生のデータ • 17変数 • studyName: 研究名(越冬隊ごと?) •
Sample Number: 標本番号(連番) • Species: ペンギンの種(学名付き) • Region: 調査した地域 • Island: 調査した島 • Stage: 発育段階 • Individual ID: 個体ID • Clutch Completion: 巣の完成度 • Date Egg: 巣に1個以上の卵が確認された日? • Culmen Length (mm): くちばしの長さ • Culmen Depth (mm): くちばしの高さ • Flipper Length (mm): 翼の長さ • Body Mass (g): 体重 • Sex: 性別 • Delta 15 N (o/oo): 窒素同位体比(δ15N) • Delta 13 C (o/oo): 炭素同位体比(δ13C) • Comments: コメント penguins 使いやすく加工されたデータ • 8変数 • species: ペンギンの種 • island: 調査した島 • bill_length_mm: くちばしの長さ • bill_depth_mm: くちばしの高さ • flipper_length_mm: 翼の長さ • body_mass_g: 体重 • sex: 性別 • year: 調査した年 Artwork by @allison_horst
とりあえず生データを確認 library(palmerpenguins) penguins_raw |> head(10) |> View()
サマリーを確認 library(summarytools) penguins_raw |> dfSummary() |> view() • 欠測値(NA)がある。 •
値がすべて同じ列がある。 • 同じ個体IDが3回出現している。
変数間の関係の概要 penguins_raw |> dplyr::select( #余分な変数を除外 !c( `Sample Number`, Region, Stage,
`Individual ID`, Comments ) ) |> GGally::ggpairs( aes(colour = Species), title = "Palmer Penguins Raw" )
変数間の関係の概要 penguins_raw |> dplyr::select( #余分な変数を除外 !c( `Sample Number`, Region, Stage,
`Individual ID`, Comments ) ) |> GGally::ggpairs( aes(colour = Species), title = "Palmer Penguins Raw" ) Date Egg x studyName と Species x Island が気になる。
研究名ごとの期間 penguins_raw |> group_by(studyName) |> summarise(Start = min(`Date Egg`), End
= max(`Date Egg`)) # studyName Start End # <chr> <date> <date> #1 PAL0708 2007-11-09 2007-12-03 #2 PAL0809 2008-11-02 2008-11-25 #3 PAL0910 2009-11-09 2009-12-01
調査した島と生息するペンギンの種 penguins_raw |> xtabs(~ Species + Island, data = _)
# Island #Species Biscoe Dream Torgersen # Adelie Penguin (Pygoscelis adeliae) 44 56 52 # Chinstrap penguin (Pygoscelis antarctica) 0 68 0 # Gentoo penguin (Pygoscelis papua) 124 0 0
「オスの方がメスよりわずかに大きい」? penguins_raw |> drop_na(Sex) |> ggplot(aes(x = Sex, y =
`Body Mass (g)`)) + geom_violin(aes(colour=Sex, fill = Sex)) + geom_boxplot(width = 0.3) + geom_jitter(width = 0.15, height = 0) + facet_wrap(vars(Species)) + labs( title = "性別と体重", x = "性別", y = "体重 (g)", colour = "性別", fill = "性別" ) + theme(text = element_text(size = 18))
to be continued... 今後の予定: 1. データセットの紹介(今回) 2. データクリーニング ◦ penguins_rawからpenguinsへ
3. 可視化例 4. 分析例 ◦ シンプソンのパラドクス ◦ 次元縮約 ◦ クラスタリング ◦ 判別モデル ◦ などなど いらすとやにはアデリーペン ギンがいなかった…… タイトルの「パーマーステーションのペ ンギンたち」は『ウォーターシップダウ ンのウサギたち』をもじったつもり。