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
Rの基礎 5 データフレーム
Search
xjorv
January 19, 2021
Education
250
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rの基礎 5 データフレーム
Rの基礎5では、Rでのデータ取り扱いの重要要素の一つである、データフレームについて説明します。
xjorv
January 19, 2021
More Decks by xjorv
See All by xjorv
コンパートメントモデル
xjorv
3
6.1k
コンパートメントモデルをStanで解く
xjorv
0
540
生物学的同等性試験 検出力の計算法
xjorv
0
3.7k
生物学的同等性試験ガイドライン 同等性パラメータの計算方法
xjorv
0
6.7k
粉体特性2
xjorv
0
2.6k
粉体特性1
xjorv
0
3k
皮膜5
xjorv
0
2.4k
皮膜4
xjorv
0
2.3k
皮膜3
xjorv
0
2.3k
Other Decks in Education
See All in Education
Visionary Initiative: Future Intelligence — Laying the foundations for the future of science, intelligence, and society | Science Tokyo
sciencetokyo
PRO
0
340
エビデンスベースト英語教育入門:エビデンスは科学的知見(だけ)ではない,制度だ!
terasawat
0
210
Soluciones al examen de Geografía 2026. JUNIO (Convocatoria Ordinaria)
juanmartin2026
1
11k
1人 × AI、1か月でここまで作れる ー 数年前の外注換算3.8〜7.4億円・241〜379人月分の作業を、AI費用 約10万円・31日で
frievea
0
520
Portable & Reproducible Research Environments in the Age of AI Agents
denkiwakame
0
750
AIの力を100%引き出すために
frievea
0
530
未踏峰連山 Frontiers: Creating and Conquering Untrodden Peaks
ishii_mit
1
130
Visionary Initiative: Future Intelligence 「未来の知性と社会の礎を築く」|Science Tokyo(東京科学大学)
sciencetokyo
PRO
0
1.8k
学生のうちに考えておきたい信頼の話
suisan
1
800
One Year of Learning English with AI @エンジニア英語キャリア Meetup #3
kekekenta
0
230
【2026年サマースクール用ZEPメタバース校舎操作ガイド】
ainischool
0
120
AI時代のセキュリティ監査
matshogo
PRO
0
120
Featured
See All Featured
Utilizing Notion as your number one productivity tool
mfonobong
4
590
The SEO identity crisis: Don't let AI make you average
varn
0
560
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
670
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Testing 201, or: Great Expectations
jmmastey
46
8.3k
Bash Introduction
62gerente
615
220k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
820
Practical Orchestrator
shlominoach
192
12k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.6k
Crafting Experiences
bethany
1
350
Transcript
Rの基礎 5 データフレーム 2020/8/6 Ver. 1.0
データフレームとは? • Excelの表のようなもの • Rでデータを扱う時に多用する データフレームは data.frame(列名1=Vector1, 列名2=Vector2) という形で書く (Vector1と2は同じ長さでないとダメ)
データフレームのインデックス インデックスは[行, 列]と書く 数値と文字列の 6行2列のdataframe 1行1列は1 5行2列はe 2行6列はないのでNULL 行 列
データフレームの要約 データフレームの要約はsummary関数で得ることができる • 数値は最大・最小・平均値など • factor(因子)は要素の数 を返す
データフレームの行・列数 行はnrow、列はncol、行列数はdimで調べられる irisは150行5列のデータ
データフレームの列名・行名 データフレームの列・行には名前がついている • colnames関数で列名、rownames関数で行名を取得できる • 2つのnames関数に代入することで、列・行名を変更できる
データフレームの一部を確認する データが多い場合には一部だけを確認できる head は上から6行 tail は下から6行
データフレームの計算: 列を使う ベクトルとして列を取り出して計算に使える • データフレームは同じ長さの ベクトルのリスト • 各列がベクトルに当たる • インデックスで列を取り出す
とベクトルとして扱える
データフレームの列を取り出す インデックスだけではなく、列名からも呼び出せる 列名での呼び出しは、 データフレーム$列名 となる *呼び出した結果はベクトルになる(データフレームは列をベクトルとしたリストだから)
データフレームの計算: 行を取り出す 行は取り出してもベクトルにならない • 列を取り出すとベクトルとして扱える • 行はデータフレームのまま *classはデータの型を返す関数。ベクトルを引数にすると要素の型を返す
データフレームの計算: 繰り返し for文で繰り返し計算することが多い 1:nrow(data.frame)のような形で 各行に対して計算することも多い 左は4列目のデータの和 sum(iris[,4])でも同じ計算ができる
データフレームの計算: apply 列、行に関数を適用したいときにapplyを用いる apply(df, 行列, 関数) df: データフレーム 行列: 行なら1、列なら2
関数: 計算に使う関数
まとめ • データフレームはExcelの表のようなもの • 同じ長さのベクトルのリストである • データフレームの計算法はたくさんある • apply関数を用いて計算する事が多い