Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
データフレームを操作/how_to_manipulate_dataframes
Search
florets1
June 08, 2023
Programming
430
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
データフレームを操作/how_to_manipulate_dataframes
florets1
June 08, 2023
More Decks by florets1
See All by florets1
整数計画ソルバーで遊ぼう/using_an_integer_programming_solver_in_r
florets1
0
43
データ分析をはじめよう/lets_start_data_analysis
florets1
2
1.1k
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
850
Tableauとggplot2の背景/Background_of_Tableau_and_ggplot2
florets1
0
100
Rで学ぶデータハンドリング入門/Introduction_to_Data_Handling_with_R
florets1
0
170
人工知能はクロスジョインでできている/AI_Is_Built_on_Cross_Joins
florets1
0
130
仮説の取扱説明書/User_Guide_to_a_Hypothesis
florets1
4
500
複式簿記から純資産を排除する/eliminate_net_assets_from_double-entry_bookkeeping
florets1
1
520
カイ二乗検定は何をやっているのか/What_Does_the_Chi-Square_Test_Do
florets1
7
2.6k
Other Decks in Programming
See All in Programming
Family mrubyの進捗
kishima
1
130
Kiroで創り、AgentCoreで繋ぐ!AWSで実践する「AI-DLC」から「AIエージェント統合」までの最新地図
licux
4
700
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
120
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
300
setup-vp GitLab対応の裏側
naokihaba
0
110
Java 27新機能 / Java 27 new features
kishida
2
150
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.8k
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
0
1.5k
Building an Out-of-Order CPU
latte72
1
790
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
500
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
250
Jetpack Compose メカニズム
skydoves
0
450
Featured
See All Featured
Facilitating Awesome Meetings
lara
57
7.1k
Faster Mobile Websites
deanohume
310
32k
Tell your own story through comics
letsgokoyo
1
1.1k
Designing Powerful Visuals for Engaging Learning
tmiket
1
570
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
280
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
330
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
The untapped power of vector embeddings
frankvandijk
2
1.9k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
430
Music & Morning Musume
bryan
48
7.4k
Transcript
1 2023.06.10 Tokyo.R #106 データフレームを操作
Rでデータを加工してレポート
Tidyverse データの整形がはかどるライブラリ
← 代入
c() ベクトルを作る ベクトルの1番目の要素x[1]の値は0.3
▷ パイプライン x ^ 2 %>% sum %>% sqrt という書き方もあります。
tibble() データフレームを作る
この資料の表記ルール データフレームやCSVファイルのようなテーブル形状のデータを右図のように表記します。 =
架空の業務システム order_no 1 client AAA 1 abcd 2300 100 seq_no
unit_price item qty 2 efg 1500 90 (new)
order_no 1 client AAA orders (注文ヘッダー) 1 abcd 2300 100
seq_no unit_price item qty 2 efg 1500 90 (new)
1 abcd 2300 100 seq_no unit_price item qty 2 efg
1500 90 (new) details (注文明細) order_no 1 client AAA items (商品)
read_csv() ファイルを読み込む データフレーム(tibble)として読み込まれます。
行を抽出して列を選択する filter() とselect() ▷
inner_join() 結合する details orders × =
さらに結合する items × =
mutate() 列を追加する
結果をdに代入 d
在庫タイプ別の合計金額 ▷ d
注文番号ごとの合計金額 ▷ d
注文番号ごとの合計金額をsに代入 s ▷ d 注文番号ごとの合計金額
dとsを結合
注文番号ごとの割合
注文番号ごとの割合 nestとmapを使って書く例 中間変数無しで一気通貫に書ける
nestとmapの処理の流れ(1)
nestとmapの処理の流れ(2)
nestとmapの処理の流れ(3)
nestとmapの処理の流れ(4)
nestとmapの処理の流れ(5)
まとめ Tidyverse 便利なライブラリ ← 代入 C() ベクトル ▷ パイプライン tibble()
データフレーム read_csv() 読み込む filter() 抽出 select() 選択 inner_join() 結合 mutate() 列を追加 group_by() グループ化 summarise() 集計 group_nest() 入れ子にする map_dbl() リストに関数適用 ~ . ラムダ式 unnest() 入れ子を解除