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
Rでドレミ/Do-Re-Mi_with_R
florets1
0
120
整数計画ソルバーで遊ぼう/using_an_integer_programming_solver_in_r
florets1
0
47
データ分析をはじめよう/lets_start_data_analysis
florets1
2
1.1k
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
860
Tableauとggplot2の背景/Background_of_Tableau_and_ggplot2
florets1
0
100
Rで学ぶデータハンドリング入門/Introduction_to_Data_Handling_with_R
florets1
0
180
人工知能はクロスジョインでできている/AI_Is_Built_on_Cross_Joins
florets1
0
140
仮説の取扱説明書/User_Guide_to_a_Hypothesis
florets1
4
500
複式簿記から純資産を排除する/eliminate_net_assets_from_double-entry_bookkeeping
florets1
1
530
Other Decks in Programming
See All in Programming
mrbgem 三角測量 開発
ogom
0
200
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
190
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
460
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
450
Simple Storage Service(S3) is not simple
iwatsukayura
0
210
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
350
技術的負債の返済は、AI時代の複利で効く投資 — 経営としての意思決定とその遂行
curekoshimizu
1
2.2k
Jetpack Compose Mechanisms
skydoves
2
490
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
540
The Rails Doctrine Decade
koic
2
510
SalesForceを内製化!? ~ HR事業を支える顧客管理基盤のインフラを大公開 ~
oku053
0
140
Workers Cache を知る
syumai
0
340
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
470
Building AI with AI
inesmontani
PRO
1
1.3k
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.2k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
The Invisible Side of Design
smashingmag
301
52k
The World Runs on Bad Software
bkeepers
PRO
72
12k
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
460
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
610
Fantastic passwords and where to find them - at NoRuKo
philnash
52
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() 入れ子を解除