Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Rの基礎2_変数と関数.pdf
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
xjorv
April 22, 2021
Education
69
0
Share
Rの基礎2_変数と関数.pdf
xjorv
April 22, 2021
More Decks by xjorv
See All by xjorv
コンパートメントモデル
xjorv
3
5.9k
コンパートメントモデルをStanで解く
xjorv
0
500
生物学的同等性試験 検出力の計算法
xjorv
0
3.6k
生物学的同等性試験ガイドライン 同等性パラメータの計算方法
xjorv
0
6.5k
粉体特性2
xjorv
0
2.6k
粉体特性1
xjorv
0
2.9k
皮膜5
xjorv
0
2.4k
皮膜4
xjorv
0
2.3k
皮膜3
xjorv
0
2.3k
Other Decks in Education
See All in Education
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visualisation (4019538FNR)
signer
PRO
1
2.9k
Modelamiento Matematico (Ingresantes UNI 2026)
robintux
0
260
Introduction - Lecture 1 - Advanced Topics in Big Data (4023256FNR)
signer
PRO
2
2.3k
[2026前期火5] 論理学(京都大学文学部 前期 第1回)「ハルシネーションを外部世界との対応を考えずに見分ける方法」
yatabe
0
350
地区危機管理委員会 出前セミナー「ロータリーにおける危機管理」:膳所 和彦 氏(国際ロータリー第2720地区 パストガバナー・日田ロータリークラブ・医療法人恒心会ぜぜ医院 理事長):2720 Japan O.K. ロータリーEクラブ2026年2月16日卓話
2720japanoke
1
620
From Participation to Outcomes
territorium
PRO
0
420
SSH公開鍵認証 / 02-b-ssh
kaityo256
PRO
0
140
What workforce agencies must have in place to compete for and deliver on RESTART grants
territorium
PRO
0
130
Information Architectures - Lecture 2 - Next Generation User Interfaces (4018166FNR)
signer
PRO
1
1.9k
Fulbright DAI 2025 學人經驗分享
joannie
0
740
Railsチュートリアル × 反転学習の事例紹介
yasslab
PRO
3
180k
SL AMIGOS 教育格差と私たちの取り組み - スリランカの支援学校への支援プロジェクト:リシンドゥ リオ 氏 (別府溝部学園短期大学 ビジネス観光コース 留学生):2720 Japan O.K. ロータリーEクラブ2026年4月6日卓話
2720japanoke
0
520
Featured
See All Featured
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
2
670
Paper Plane (Part 1)
katiecoart
PRO
0
6.4k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
470
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
YesSQL, Process and Tooling at Scale
rocio
174
15k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
360
Docker and Python
trallard
47
3.8k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
150
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
210
What's in a price? How to price your products and services
michaelherold
247
13k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
Transcript
Rの基礎 2 変数と関数 2020/8/5 Ver. 1.0
変数と関数とは? 変数 関数 数字や文字を入れておく箱 数字を入れると、別のものを吐き出す箱 “犬” Dog 変数 “犬” 関数
c(5, 10, 15) mean 10 代入 引数 返り値 *Rではmeanは平均値を計算する関数
変数の作り方 • 変数名は英数字のみで、先頭の文字には数字を使えない • 変数には<-を使って代入する • 変数名を入力すると、代入したものが呼び出される Xに1を代入 Xを呼び出し 変数は電卓のメモリー機能(M+など)と同じようなもの
変数の扱い方 • 変数は演算に利用できる • 変数には型がある Xに1を代入すると、 • X + 10は11になり、演算できる
• Xの型はNumericになる Yに“dog”を代入すると、 • Yの型はCharacterになる 1. class(◦◦)で◦◦の型を知ることができる 2. 変数の型は代入されたものによって勝手に決まる(型推論)
変数の型と演算 • 型が違うと計算できず、エラーがでる • 型をclass関数でチェックし、間違いを探す 1 + “dog” は型が演算の形にあっていないので、計算できない
関数 • 関数とは、引数を演算し、返り値を返すもの • Rには多数の関数が登録されている(組み込み関数) ひきすう mean()は平均値、sd()は標準偏差、summary()はデータの要 約を計算するための関数、xが引数となる。
引数と返り値 • 引数は、関数の後のカッコの中に入れる変数のこと • 返り値は、関数で生成するもの xがmean関数の引数、3.5が返り値となる
関数を作る 自分で関数を作ることもできる • 関数も変数のように代入して作る • 関数はfunction(引数){処理}という形で書く • 返り値はreturn(返り値)で指定する *返り値はreturn関数を使わず、返り値を書くだけでも決定される
まとめ • 変数は数字・文字列を保存しておくための箱 • 関数は引数を処理して返り値を返すもの • 関数はfunction(引数){処理}で記述できる • 関数の返り値はreturn(返り値)で指定する