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
Try-R-jp
Search
Takahiro Sumiya
March 01, 2019
Education
150
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Try-R-jp
Takahiro Sumiya
March 01, 2019
More Decks by Takahiro Sumiya
See All by Takahiro Sumiya
DME-20260710
gnutar
0
21
卒論・修論執筆における生成AI 活用とAI 不安:広島大学での実態調査 (3)/CE185
gnutar
0
39
生成AI活用セミナー/GAI-workshop
gnutar
0
210
GAI-FD2025
gnutar
0
140
卒論・修論執筆における生成AI 活用とAI 不安:広島大学での実態調査 (2)/CE180
gnutar
0
97
大学教育現場と著作権/DME-2025-06-04
gnutar
0
100
著作権と授業に関する出前講習会/dme-2025-05-01
gnutar
0
290
Excelグラフはどうしてダサいのか/csd2024-3-sumiya
gnutar
1
400
出前講習会-西海市教育委員会/DME-2025-02-10
gnutar
0
140
Other Decks in Education
See All in Education
セキュリティ担当がいない中小医療機関を院外のRISSはどう支えるべきか / How External RISS Can Help Small Medical Institutions
eller86
1
200
オンラインコミュニティ TRY部 体験マニュアル
ytapples613
0
370
Portable & Reproducible Research Environments in the Age of AI Agents
denkiwakame
0
730
【デザイナー就活講座】 デザイナー就活市場・企業探し・ポートフォリオのポイント
koheihasebe
0
600
人間のために、人間と共に働く時代の終わりの始まり
frievea
0
190
DecisionesEjecutivasCrisis
mariooc
0
330
Réunion des directrices et directeurs des écoles de la circonscription de Jonzac - 31 août 2026
fmarot
0
140
Beyond the Prompt: Programming as a Pathway to Statistical Thinking
minecr
0
370
One Year of Learning English with AI @エンジニア英語キャリア Meetup #3
kekekenta
0
220
Visionary Initiative: Materials-Positive Society — Evolving “Things,” empowering a positive society | Science Tokyo
sciencetokyo
PRO
0
270
Plano urbano de Madrid desde el Ensanche al s. XXI (2ª parte).
juanmartin2026
1
83k
輻射安全管理系統2.0暨輻防e++學園平台說明會
aecrp
0
2.1k
Featured
See All Featured
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
65k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
510
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
BBQ
matthewcrist
89
10k
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.1k
Exploring the relationship between traditional SERPs and Gen AI search
raygrieselhuber
PRO
3
4.3k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
120
120k
It's Worth the Effort
3n
188
29k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Transcript
F3S講習会 統計データ処理ツールを使ってみよう (R入門) 広島大学情報メディア教育研究センター 隅谷孝洋
‣ R is a language and environment for statistic computing
and graphics [Rとは、統計計算と統計グラフのための 言語であり、(実行)環境である。] https://www.r-project.org/about.html
Γ͍ͨ͜ͱ ॲཧखॱ ʢΞϧΰϦζϜʣ 1: int main(int argc,char 2: int i=0;
3: char c; 4: while(i==0){ 5: c=getchar(); ϓϩάϥϜ ࣮ߦʂ (プログラミング)言語 (実行)環境
本日のメニュー 1. Rの準備 2. コマンドの投入と結果の表示 3. Excelのデータの読み込み 4. データの要約 5.
データの視覚的な確認 6. いくつかの統計分析手法を使ってみる
1. Rの準備
Rの準備 ‣ R ✓ R実行環境 ✓ これだけでも利用可 ‣ RStudio ✓
Rの(もっと便利な)実行環境 ✓ 普段はこちらを利用 ʴ
Rのインストール https://www.r-project.org/about.html (日本のミラーサイトを選択) $3"/ͷαΠτ Download R for (Mac)
OS X → R-3.5.1.pkg (最新版) Download R for Windows → Install R for the rst time → Download R 3.5.1 for Windows
RStudio のインストール https://www.rstudio.com (下の方までスクロールして...) RStudio 1.1.463 - Windows
Vista/7/8/10 RStudio 1.1.463 - Mac OS X 10.6+ (64-bit)
RStudioを起動してみる νΣοΫʂ
2. コマンドの投入と結果の表示
まずは、ここに 入れてみましょう
電卓として使う ‣ 式を打ち込んでみよう > 1+1 > 100/3 > 100/3*3 ‣
かっこも使える > (3+5)*7 > 3+5*7 # 結果が違う
Rのコマンドをファイルとして残しておこう ‣ 「プロジェクト」を作ると、一連のファイル をひとまとめにしやすい ✓ 命令(コマンド)を記したファイル ✓ データファイル ✓ 結果のグラフ
‣ File → New Project → New Directory → New Project
Rのコマンドをファイルとして残しておこう ‣ File→New File→R Script ίϚϯυΛ ॻ͍ͯɺ DUMFOUFS
݁Ռ ͪ͜Βʹग़Δ
高級な電卓として使う ‣ ベキ乗 ^ とか > 2^16 ‣ 関数とかも使える >
sin(pi/2) # > exp(1) # > factorial(10) # > choose(5,2) # sin ⇡ 2 10! 5C2 e1
グラフを描いてみよう > plot(c(5,5,4,3,3,4,1,1,1)) > x=c(5,4,3,3,1,4,1,1,1) # 変数に代入 > plot(x) #
スッキリ > plot(x,type="b") # これ、何のデータ? > plot(x,type="b",ylim=c(6,1)) > yr=2010:2018 > plot(yr,x,type="b",ylim=c(6,1))
Rでは、変数(オブジェクト)の中身の基本はベクトル > x # 変数名のみ入れると内容の表示 > x+10 # 数学のベクトルとは違う >
x+c(10,100) # 長さが違うものを足すと? > x[1] # 最初の数値を取り出す > x[c(1,3,5)] # 1,3,5番目を取り出す
一度終了して、再び開いてみよう ‣ コマンドファイルに名前をつけて保存 ‣ RStudio の終了 ‣ フォルダ内のファイルの確認 ‣ プロジェクトファイルをダブルクリックし
て再起動
3. Excelデータの読み込み
Excelのデータは、CSVにして読み込み ‣ Bb9から"carp.xlsx"をダウンロード ‣ Excelで開いて内容を確認 ‣ CSV (UTF-8) で保存 →
carp.csv ‣ Windowsの人は「CSV」で保存
CSVファイルを読み込むと「データフレーム」ができる > read.csv("carp.csv") # 画面に出ちゃう > c=read.csv("carp.csv") # 変数cに保存 >
c # 読めたか確認 ‣ 「データフレーム」は、名前がついたベクト ルの集まり > c$身長 # 「身長」という名前の列 > c$身長[3] # その三番目の値 > mean(c$身長) # 身長の平均
データフレーム(続き) > c$BMI=c$体重/(c$身長/100)^2 # BMI を計算 > c[c$BMI>30,] # BMI
が30より大きい選手 BMI = Weight(kg) Height(m) 2
おまけ1:こんなのもあります Excelのファイルを直接読み込む ‣ install.packages("readxl") ‣ library(readxl) ‣ carp=read_excel("carp.xlsx",1) ‣ dragons=read_excel("carp.xlsx",2)
4. データの要約
summary という関数が便利 ✓ summary(c) ‣ 数値データ ✓ Min(最小値),1st Qu.(第1四分位 点),
Median(中央値), Mean(平 均), 3rd Qu. (第3四分位点), Max(最大値) ‣ カテゴリーデータ ✓ 頻度
グループの要約 > # BMIが26より大きい選手のsummary > summary(c[c$BMI>26,]) > # ポジションごとの身長のsummary >
tapply(c$身長,c$ポジション,summary)
5. データの視覚的な確認
度数分布図、散布図、箱ヒゲ図 > hist(c$身長) ‣ Macの人...化けていますね orz > # ヒラギノ角ゴシックをW3使うように指定 >
par(family = "HiraKakuProN-W3") > hist(c$身長)
気を取り直して、度数分布図、散布図、箱ヒゲ図 > hist(c$身長) # 度数分布図 > barplot(table(c$ポジション)) > plot(c$身長,c$体重) #
散布図 > plot(c) # 散布図行列 > plot(c[,c(4,5,6,9)]) > boxplot(c$身長) # 箱ひげ図 > boxplot(c$身長[c$ポジション=="投手"], c$身長[c$ポジション!="投手"], names=c("投手","それ以外"),ylab="身長")
おまけ2:こんなのもあります 心理学研究用パッケージ > install.packages("psych") > library(psych) > pairs.panels(c[,c(4,5,6,9)])
ググって描いてみよう (1)
ググって描いてみよう (2)
6. いくつかの統計分析手法を使ってみる
線形回帰 > plot(c$体重 ~ c$身長) > result=lm(c$体重 ~ c$身長) >
abline(result) > summary(result)
左利きが多いのか? 世間一般の左利き率が0.1として、二項検定をおこなってみる > summary(c$投) > binom.test(13,13+56,0.1) > cp=c[c$ポジション=="投手",] > summary(cp$投)
> binom.test(11,11+23,0.1)
Rのメリット ‣ 統計計算に特化 ‣ グラフがキレイ ‣ コマンド(=テキスト情報)でやったこと が残るので、再現が簡単 ‣ 新しい手法がどんどん実装される
‣ 無料!オープンソース