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
76
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rの基礎2_変数と関数.pdf
xjorv
April 22, 2021
More Decks by xjorv
See All by xjorv
コンパートメントモデル
xjorv
3
6k
コンパートメントモデルをStanで解く
xjorv
0
520
生物学的同等性試験 検出力の計算法
xjorv
0
3.7k
生物学的同等性試験ガイドライン 同等性パラメータの計算方法
xjorv
0
6.6k
粉体特性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
Case Studies and Future Research - Lecture 12 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
180
勾配ブースティングと決定木の話 / gradient boosting and decision trees
kaityo256
PRO
6
1.3k
2026年度春学期 統計学 第4回 データを「分布」で見る (2026. 4. 30)
akiraasano
PRO
0
140
The Lotus and the Frog
vyadav
0
120
AI時代に、 なぜ英語を勉強するのか
empelt
0
110
LinkedIn
matleenalaakso
0
4.4k
[2026前期火5] 論理学(京都大学文学部 前期 第4回)「 ならば(→)の導入と証明ネット」
yatabe
0
450
「機械学習と因果推論」入門 ⑤ 因果効果推定の一般化
masakat0
0
120
AWS Certified Generative AI Developer - Professional Beta 不合格体験記
amarelo_n24
1
370
SL AMIGOS 教育格差と私たちの取り組み - スリランカの支援学校への支援プロジェクト:リシンドゥ リオ 氏 (別府溝部学園短期大学 ビジネス観光コース 留学生):2720 Japan O.K. ロータリーEクラブ2026年4月6日卓話
2720japanoke
0
630
共感から、つくる: 変わり続ける自分と、誰かのための創造
micknerd
1
390
Lectura 1 (PIT : Python Basico)
robintux
0
360
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
160
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
530
AI: The stuff that nobody shows you
jnunemaker
PRO
8
720
Building Flexible Design Systems
yeseniaperezcruz
330
40k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
1.7k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
370
BBQ
matthewcrist
89
10k
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(返り値)で指定する