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
20190605_初心者向けLT_Excel使いのためのR入門
Search
NobuakiOshiro
PRO
June 05, 2019
Science
470
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
20190605_初心者向けLT_Excel使いのためのR入門
https://fukuoka-r.connpass.com/event/131360/
NobuakiOshiro
PRO
June 05, 2019
Transcript
23 slides
初心者向けLT ~ 5分で始める Excel使いのためのR言語入門 ~ 2019/06/05 大城
自己紹介(省略) • NOB DATAというデータ 分析の会社をやっており ます(at 福岡)
本LTの対象者 • Excelもいいけど、限界を感じている or もっと便利にしたい • レポート、分析、可視化、自動化、etc.. • プログラミングは初心者 or
初めて • 環境構築が楽な方法 & アドバイスもらえる状況が嬉しい ちょっとRでやってみよう
流れ • 0. RとRstudioのインストール • 1. RStudio起動 • 2. Excelファイルの入出力
• 3. 読み込んだデータの活用
0. RとRstudioのインストール • R • Windows or Mac or Linux
• https://cran.r-project.org/ • RStudio • https://www.rstudio.com/pro ducts/rstudio/download/
1. RStudio起動
プロジェクト作成
作業ディレクトリ変更
試しに実行
コードの記載 • ```{r}で囲まれたブロック に書いておくと再利用でき て良い • irisという花のデータを見る 場合はこんな感じ • Runボタンで実行する行や
チャンクを選べる アヤメの花のデータ
その他、Rstudioの詳細は kazutanさんの資料などをご参考に。 • https://kazutan.github.io/JSSP2018_spring/intro_rstudio.html
2. Excelファイルの入出力 • まずはライブラリのインストー ル • openxlsxを使う例(xlsxの拡張子 に対応。xlsはNG) • インストール&ロード
• install.packages(‘openxlsx’) #初回のみ • library(openxlsx)
2-1. ファイル出力 • 先にirisデータを書き出してみる • こんな感じ(1行) • write.xlsx(iris, file =
"writeXLSX1.xlsx") • 頑張ればシートやフォントの変更 も可能 • ヘルプ見る場合は ??write.xlsx
2-2. ファイル入力 • 先ほどのエクセルファイルを読 み込みする場合はこちら • data <- read.xlsx('writeXLSX1.xlsx’) •
読み込んだ変数はRStudio上で データもチェックできる
3. 読み込んだデータの活用 • ここまででExcelデータをRで使える状態にできた • 集計、可視化、分析、etc.. 。Rで色々できる あとは煮るなり焼くなり自由に。
3. 読み込んだデータの活用 • 例えば「R言語 iris データ分析」などで ググるとたくさん出 てくる
3-1. データ可視化 • ggpairsとか使うと実質1行で色々わかる • library(ggplot2) #先にinstall.packagesすること • library(GGally) •
ggpairs(data, aes_string(colour="Species", alpha=0.5))
3-2. ピボットテーブル • エクセルのような機能のパッ ケージもある • #install.packages("rpivotTable") • library(rpivotTable) •
rpivotTable(data, rows = colnames(data[4]), rendererName='Heatmap', cols = colnames(data[5]), width = "100%", height = "400px")
3-3. 決定木分析 • コード例 • library(rpart) • library(partykit) • iris.part
<- as.party(rpart(Species ~ ., data=data)) • iris.part • plot(iris.part)
4. レポート化 • RStudio使ってればKnitボタ ン押すだけ • HTMLでもPDFでもいける
ご参考 : どこかで詰まったら • r-wakarangというslackのコミュニティがあるので、そこに質問するのが吉 • 参考 https://qiita.com/uri/items/5583e91bb5301ed5a4ba • Rおじさん達が早押しで答えてくれるはず・・!!
まとめ • Excelユーザーでも5分くらいでRユーザーに! • データの入出力さえ押さえれば結構便利 • 困ったらRおじさん達に相談してみよう
Enjoy..!!
More Decks by NobuakiOshiro
See All by NobuakiOshiro
20261105_選挙後の中東見通し_CodexとPro比較_13枚_大城作成分(公開用v4)
doradora09
PRO
0
22
20261103締切_中東情勢週次報告_本編10枚_補足6枚_大城作成分(過去資料)
doradora09
PRO
0
14
20261027締切_中東情勢週次報告_本編10枚_補足6枚_大城作成分(過去資料)
doradora09
PRO
0
12
20261020締切_中東情勢週次報告_本編12枚_補足4枚_大城作成分(過去資料)
doradora09
PRO
0
10
20261013締切_中東情勢週次報告_本編12枚_補足2枚_大城作成分(過去資料)
doradora09
PRO
0
9
20261006締切_中東情勢週次報告_本編12枚_補足4枚_大城作成分
doradora09
PRO
0
49
20260929締切_中東情勢週次報告_BRS統合版_本編12枚_補足4枚_大城
doradora09
PRO
0
37
20260922締切_中東情勢_週次レポート_18枚_大城作成分
doradora09
PRO
1
61
20260915締切_中東情勢_初心者向け週次レポート_17枚_大城作成分
doradora09
PRO
0
49
Other Decks in Science
See All in Science
不動産業界における業界特化のデータ整備とAI活用 ─Vertical DataとVertical AI─
estie
1
1.2k
AWS WAFのAIトラフィック収益化機能を考えてみる_20260626
masakiokuda
1
140
Conwayの法則を"ちゃんと"使うために — 原典でConwayは何を言っていたのか
bonotake
10
7.9k
1. CPC理論の展開と集合的知能モデル(JSAI2026 KS-27 集合的予測符号化と新たな知性の時代)
hayashiyus884
1
440
データベース06: SQL (3/3) 副問い合わせ
trycycle
PRO
1
1.2k
データベース14: B+木 & ハッシュ索引
trycycle
PRO
0
1k
生成AIが科学とRAにもたらしていること:メタサイエンスの視点から
rmaruy
0
180
[第67回 CV勉強会@関東] CV × Scientific Figures / kantoCV 67th CVPR 2026
lychee1223
0
280
データベース04: SQL (1/3) 単純質問 & 集約演算
trycycle
PRO
0
1.8k
データベース11: 正規化(1/2) - 望ましくない関係スキーマ
trycycle
PRO
0
1.8k
「念のためのログ保存」を組織全体でやめるためのポリシーと仕組み作り
i2tsuki
4
430
Where does the rigor go? Research software and the future of trustworthy science.
arfon
0
430
Featured
See All Featured
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
810
Scaling GitHub
holman
464
140k
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
1
240
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
2k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
670
Embracing the Ebb and Flow
colly
88
5.2k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
570
What does AI have to do with Human Rights?
axbom
PRO
1
2.5k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
540
GraphQLとの向き合い方2022年版
quramy
50
15k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
360
Test your architecture with Archunit
thirion
2
2.5k