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の基礎 3 ベクターの操作
Search
xjorv
January 17, 2021
Education
0
240
Rの基礎 3 ベクターの操作
Rの基礎3では、Rでデータを取り扱う場合の基礎となる、ベクター(Vector)の作り方や使用方法を説明します。
xjorv
January 17, 2021
Tweet
Share
More Decks by xjorv
See All by xjorv
コンパートメントモデル
xjorv
1
5.4k
コンパートメントモデルをStanで解く
xjorv
0
440
生物学的同等性試験 検出力の計算法
xjorv
0
3.4k
生物学的同等性試験ガイドライン 同等性パラメータの計算方法
xjorv
0
6k
粉体特性2
xjorv
0
2.4k
粉体特性1
xjorv
0
2.8k
皮膜5
xjorv
0
2.2k
皮膜4
xjorv
0
2.1k
皮膜3
xjorv
0
2.1k
Other Decks in Education
See All in Education
Data Processing and Visualisation Frameworks - Lecture 6 - Information Visualisation (4019538FNR)
signer
PRO
1
2.4k
Open Source Summit Japan 2025のボランティアをしませんか
kujiraitakahiro
0
690
i-GIP 2025 中高生のみなさんへ資料
202200
0
480
Education-JAWS #3 ~教育現場に、AWSのチカラを~
masakiokuda
0
160
新卒研修に仕掛ける 学びのサイクル / Implementing Learning Cycles in New Graduate Training
takashi_toyosaki
1
140
2025年度春学期 統計学 第3回 クロス集計と感度・特異度,データの可視化 (2025. 4. 24)
akiraasano
PRO
0
120
Tangible, Embedded and Embodied Interaction - Lecture 7 - Next Generation User Interfaces (4018166FNR)
signer
PRO
0
1.7k
日本の教育の未来 を考える テクノロジーは教育をどのように変えるのか
kzkmaeda
1
200
より良い学振申請書(DC)を作ろう 2025
luiyoshida
1
3.2k
AIの時代こそ、考える知的学習術
yum3
2
160
Constructing a Custom TeX Ecosystem for Educational Institutions—Beyond Academic Typesetting
doratex
1
8.7k
サンキッズゾーン 春日井駅前 ご案内
sanyohomes
0
290
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
29
9.5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.4k
Why Our Code Smells
bkeepers
PRO
337
57k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
31
1.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
161
15k
How to Think Like a Performance Engineer
csswizardry
24
1.7k
Large-scale JavaScript Application Architecture
addyosmani
512
110k
Music & Morning Musume
bryan
46
6.6k
It's Worth the Effort
3n
184
28k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
228
22k
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
20
1.3k
Transcript
Rの基礎 3 ベクターの操作 2020/8/5 Ver. 1.0
ベクターとは? 数値・文字列、もしくはその集合のこと “a” 1 c(1, 2) c(“a”, “b”, “c”) 文字列はベクター
数値もベクター 数値のまとまりもベクター 文字列のまとまりもベクター c()は“combine”の略で、数字や文字を”結合する”ための関数
ベクターの作り方 基本的にcを使うが、他の方法もある :(コロン)を使うと連続した数を生成できる repやseq関数で繰り返しベクターを生成できる
ベクターのインデックス ベクターにはインデックスがあり、中身をインデックスで指定できる ベクター 1 2 3 2 4 6 インデックス
代入された数値 インデックスは[]に挟んで記入する *他の言語で配列(array、list)と呼ばれるものに近い
ベクターの演算 ベクターは演算可能で、結合もできる
ベクターと関数 ベクターを引数にできる関数を使えば、演算ができる mean()は平均値 sd()は標準偏差 max()は最大値 min()は最小値 median()は中央値 を求める関数
ベクターから条件にあったものを取り出す 条件式から、Boolean(真偽値)が得られる 3と等しいものの真偽値 4より小さいものの真偽値
ベクターから条件にあったものを取り出す []内に条件式を書けば、真になるものだけ取り出せる 3と等しいものだけ取り出す 4より小さいものだけ取り出す
ベクターの要素の名前 ベクターの要素には名前を付けることができる names()は名前の取り出し/代入のための関数
名前で要素を取り出し ベクターの要素を名前で取り出すこともできる a[names(a) == “cat”]と同じ 名前と要素を結び付けてデータを引き出せる *名前と要素を結び付けるのは他言語でHashやDictionaryと呼ばれる型に当たる
まとめ • ベクターは数値や文字列の集まりのこと • ベクターは演算できる • ベクターの要素はインデックスで取り出せる • ベクターの要素には名前を付けることができる