SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
R言語超初心者
1. 基本概念
大阪大学理学部数学科 実験数学 3
担当: 鈴木譲
2015年4月13日
この章の内容
1. クラスとオブジェクト
2. クラス numeric
3. クラス logical
4. クラス character
5. オブジェクトの代入
6. クラスの変換
7. 数値関数
クラスとオブジェクト
上記3クラスに入るオブジェクトの取り扱いを学ぶ
クラス 性質 要素 (オブジェクト)
Numeric 数値 1, -3, 13.2, 7.2e-10, -0.667
logical 論理値 TRUE, FALSE, NA
character 文字列 “interesting”, “How are you?”, “-1.28”
クラス: 同じ性質をもった値の集合
オブジェクト: そのクラスの要素
クラス numeric
1+2 3
1-2 -1
2*3 6
4/5 0.8
2^3 8
(1+2*3)/5^2 0.28
is.numeric (1+2*3)/5^2) TRUE
sqrt(-3) NaN
class(NaN) numeric
pi 3.141593
sin(pi/6) 0.5
tan(pi/4) 1
クラス logical
1==2 FALSE
1<=2 TRUE
1>=2 FALSE
1!=2 TRUE
1>2 FALSE
1<2 TRUE
1==2||1>2 FALSE
1>2&&1<2 FALSE
is.logical(1>2) TRUE
Is.logical (NA) TRUE NAは、値が欠損していることを意味する
クラス character
”Thank“ “Thank”
is.character(“Thank") TRUE
paste("Thank","you") “Thank you”
past0(“Mon”,”day”) “Monday”
substring("Thank", 2,4) “han”
regexpr(“day”, “Tuesday”) 5
Characterクラスを入力とする関数
オブジェクトの代入
x<-2
x
x+3
x
x<-x+4.15
x
y<- -1.28
x+y
Xに2を代入
(初期値)
yに-1.28を代入
(初期値)
Xにx+4.15(=6.15)を代入
(更新)
何かを代入するまでは、
xはただの記号。
何らかのクラスの値をもって
そのクラスのオブジェクトになる
クラスの変換
z<-as.numeric(2<1)
z
is.logical(z)
is.numeric(z)
as.numeric(TRUE) 1となる
as.numeric(FALSE) 0となる
as.numeric(NA) NAはNAになる
as.numeric(“17”) numericの17になる
as.logical(0) 0はFALSEで他はTRUEになる
as.logical(-5)
logical クラスを
numeric クラスに変換
数値関数
関数 意味 X=1.570 (=pi/2) X=-- 0.523 (=-pi/6)
sqrt(x) 平方根 1.253314 NaN
abs(x) 絶対値 1.570796 1.047
exp(x) 指数 4.810477 0.592
log(x) 対数 0.4515827 NaN
sin(x) 正弦 0 -0.5
cos(x) 余弦 0.5 0.8660254
tan(x) 正接 Inf -0.5773503
floor(x) (絶対値の)切上げ 1 -1
trunc(x) 切下げ 1 0
round(x) 四捨五入 2 -1

Weitere ähnliche Inhalte

Andere mochten auch

ガイダンス
ガイダンスガイダンス
ガイダンスJoe Suzuki
 
相互情報量を用いた独立性の検定
相互情報量を用いた独立性の検定相互情報量を用いた独立性の検定
相互情報量を用いた独立性の検定Joe Suzuki
 
MaCaulay2 Miuraパッケージの開発と今後
MaCaulay2 Miuraパッケージの開発と今後MaCaulay2 Miuraパッケージの開発と今後
MaCaulay2 Miuraパッケージの開発と今後Joe Suzuki
 
OMNI-Prop: Seamless Node Classification on Arbitrary Label Correlation
OMNI-Prop: Seamless Node Classification on Arbitrary Label CorrelationOMNI-Prop: Seamless Node Classification on Arbitrary Label Correlation
OMNI-Prop: Seamless Node Classification on Arbitrary Label CorrelationYuto Yamaguchi
 
Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...
Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...
Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...Yuto Yamaguchi
 
Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...
Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...
Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...Taiji Suzuki
 
関西NIPS+読み会発表スライド
関西NIPS+読み会発表スライド関西NIPS+読み会発表スライド
関西NIPS+読み会発表スライドYuchi Matsuoka
 

Andere mochten auch (8)

2014 9-26
2014 9-262014 9-26
2014 9-26
 
ガイダンス
ガイダンスガイダンス
ガイダンス
 
相互情報量を用いた独立性の検定
相互情報量を用いた独立性の検定相互情報量を用いた独立性の検定
相互情報量を用いた独立性の検定
 
MaCaulay2 Miuraパッケージの開発と今後
MaCaulay2 Miuraパッケージの開発と今後MaCaulay2 Miuraパッケージの開発と今後
MaCaulay2 Miuraパッケージの開発と今後
 
OMNI-Prop: Seamless Node Classification on Arbitrary Label Correlation
OMNI-Prop: Seamless Node Classification on Arbitrary Label CorrelationOMNI-Prop: Seamless Node Classification on Arbitrary Label Correlation
OMNI-Prop: Seamless Node Classification on Arbitrary Label Correlation
 
Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...
Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...
Online User Location Inference Exploiting Spatiotemporal Correlations in Soci...
 
Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...
Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...
Minimax optimal alternating minimization \\ for kernel nonparametric tensor l...
 
関西NIPS+読み会発表スライド
関西NIPS+読み会発表スライド関西NIPS+読み会発表スライド
関西NIPS+読み会発表スライド
 

Mehr von Joe Suzuki

RとPythonを比較する
RとPythonを比較するRとPythonを比較する
RとPythonを比較するJoe Suzuki
 
R集会@統数研
R集会@統数研R集会@統数研
R集会@統数研Joe Suzuki
 
E-learning Development of Statistics and in Duex: Practical Approaches and Th...
E-learning Development of Statistics and in Duex: Practical Approaches and Th...E-learning Development of Statistics and in Duex: Practical Approaches and Th...
E-learning Development of Statistics and in Duex: Practical Approaches and Th...Joe Suzuki
 
分枝限定法でモデル選択の計算量を低減する
分枝限定法でモデル選択の計算量を低減する分枝限定法でモデル選択の計算量を低減する
分枝限定法でモデル選択の計算量を低減するJoe Suzuki
 
連続変量を含む条件付相互情報量の推定
連続変量を含む条件付相互情報量の推定連続変量を含む条件付相互情報量の推定
連続変量を含む条件付相互情報量の推定Joe Suzuki
 
E-learning Design and Development for Data Science in Osaka University
E-learning Design and Development for Data Science in Osaka UniversityE-learning Design and Development for Data Science in Osaka University
E-learning Design and Development for Data Science in Osaka UniversityJoe Suzuki
 
AMBN2017 サテライトワークショップ
AMBN2017 サテライトワークショップAMBN2017 サテライトワークショップ
AMBN2017 サテライトワークショップJoe Suzuki
 
CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要Joe Suzuki
 
Forest Learning from Data
Forest Learning from DataForest Learning from Data
Forest Learning from DataJoe Suzuki
 
A Bayesian Approach to Data Compression
A Bayesian Approach to Data CompressionA Bayesian Approach to Data Compression
A Bayesian Approach to Data CompressionJoe Suzuki
 
A Conjecture on Strongly Consistent Learning
A Conjecture on Strongly Consistent LearningA Conjecture on Strongly Consistent Learning
A Conjecture on Strongly Consistent LearningJoe Suzuki
 
A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...
A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...
A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...Joe Suzuki
 
A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...
A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...
A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...Joe Suzuki
 
研究紹介(学生向け)
研究紹介(学生向け)研究紹介(学生向け)
研究紹介(学生向け)Joe Suzuki
 
Bayesian Criteria based on Universal Measures
Bayesian Criteria based on Universal MeasuresBayesian Criteria based on Universal Measures
Bayesian Criteria based on Universal MeasuresJoe Suzuki
 
MDL/Bayesian Criteria based on Universal Coding/Measure
MDL/Bayesian Criteria based on Universal Coding/MeasureMDL/Bayesian Criteria based on Universal Coding/Measure
MDL/Bayesian Criteria based on Universal Coding/MeasureJoe Suzuki
 
The Universal Measure for General Sources and its Application to MDL/Bayesian...
The Universal Measure for General Sources and its Application to MDL/Bayesian...The Universal Measure for General Sources and its Application to MDL/Bayesian...
The Universal Measure for General Sources and its Application to MDL/Bayesian...Joe Suzuki
 
Universal Prediction without assuming either Discrete or Continuous
Universal Prediction without assuming either Discrete or ContinuousUniversal Prediction without assuming either Discrete or Continuous
Universal Prediction without assuming either Discrete or ContinuousJoe Suzuki
 
Bayesian network structure estimation based on the Bayesian/MDL criteria when...
Bayesian network structure estimation based on the Bayesian/MDL criteria when...Bayesian network structure estimation based on the Bayesian/MDL criteria when...
Bayesian network structure estimation based on the Bayesian/MDL criteria when...Joe Suzuki
 

Mehr von Joe Suzuki (20)

RとPythonを比較する
RとPythonを比較するRとPythonを比較する
RとPythonを比較する
 
R集会@統数研
R集会@統数研R集会@統数研
R集会@統数研
 
E-learning Development of Statistics and in Duex: Practical Approaches and Th...
E-learning Development of Statistics and in Duex: Practical Approaches and Th...E-learning Development of Statistics and in Duex: Practical Approaches and Th...
E-learning Development of Statistics and in Duex: Practical Approaches and Th...
 
分枝限定法でモデル選択の計算量を低減する
分枝限定法でモデル選択の計算量を低減する分枝限定法でモデル選択の計算量を低減する
分枝限定法でモデル選択の計算量を低減する
 
連続変量を含む条件付相互情報量の推定
連続変量を含む条件付相互情報量の推定連続変量を含む条件付相互情報量の推定
連続変量を含む条件付相互情報量の推定
 
E-learning Design and Development for Data Science in Osaka University
E-learning Design and Development for Data Science in Osaka UniversityE-learning Design and Development for Data Science in Osaka University
E-learning Design and Development for Data Science in Osaka University
 
UAI 2017
UAI 2017UAI 2017
UAI 2017
 
AMBN2017 サテライトワークショップ
AMBN2017 サテライトワークショップAMBN2017 サテライトワークショップ
AMBN2017 サテライトワークショップ
 
CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要CRAN Rパッケージ BNSLの概要
CRAN Rパッケージ BNSLの概要
 
Forest Learning from Data
Forest Learning from DataForest Learning from Data
Forest Learning from Data
 
A Bayesian Approach to Data Compression
A Bayesian Approach to Data CompressionA Bayesian Approach to Data Compression
A Bayesian Approach to Data Compression
 
A Conjecture on Strongly Consistent Learning
A Conjecture on Strongly Consistent LearningA Conjecture on Strongly Consistent Learning
A Conjecture on Strongly Consistent Learning
 
A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...
A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...
A Generalization of the Chow-Liu Algorithm and its Applications to Artificial...
 
A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...
A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...
A Generalization of Nonparametric Estimation and On-Line Prediction for Stati...
 
研究紹介(学生向け)
研究紹介(学生向け)研究紹介(学生向け)
研究紹介(学生向け)
 
Bayesian Criteria based on Universal Measures
Bayesian Criteria based on Universal MeasuresBayesian Criteria based on Universal Measures
Bayesian Criteria based on Universal Measures
 
MDL/Bayesian Criteria based on Universal Coding/Measure
MDL/Bayesian Criteria based on Universal Coding/MeasureMDL/Bayesian Criteria based on Universal Coding/Measure
MDL/Bayesian Criteria based on Universal Coding/Measure
 
The Universal Measure for General Sources and its Application to MDL/Bayesian...
The Universal Measure for General Sources and its Application to MDL/Bayesian...The Universal Measure for General Sources and its Application to MDL/Bayesian...
The Universal Measure for General Sources and its Application to MDL/Bayesian...
 
Universal Prediction without assuming either Discrete or Continuous
Universal Prediction without assuming either Discrete or ContinuousUniversal Prediction without assuming either Discrete or Continuous
Universal Prediction without assuming either Discrete or Continuous
 
Bayesian network structure estimation based on the Bayesian/MDL criteria when...
Bayesian network structure estimation based on the Bayesian/MDL criteria when...Bayesian network structure estimation based on the Bayesian/MDL criteria when...
Bayesian network structure estimation based on the Bayesian/MDL criteria when...
 

Kürzlich hochgeladen

UniProject Workshop Make a Discord Bot with JavaScript
UniProject Workshop Make a Discord Bot with JavaScriptUniProject Workshop Make a Discord Bot with JavaScript
UniProject Workshop Make a Discord Bot with JavaScriptyuitoakatsukijp
 
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料Takayuki Itoh
 
ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学ssusere0a682
 
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2Tokyo Institute of Technology
 
The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024koheioishi1
 
TokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentationTokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentationYukiTerazawa
 
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学ssusere0a682
 

Kürzlich hochgeladen (7)

UniProject Workshop Make a Discord Bot with JavaScript
UniProject Workshop Make a Discord Bot with JavaScriptUniProject Workshop Make a Discord Bot with JavaScript
UniProject Workshop Make a Discord Bot with JavaScript
 
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
生成AIの回答内容の修正を課題としたレポートについて:お茶の水女子大学「授業・研究における生成系AIの活用事例」での講演資料
 
ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習105 -n人囚人のジレンマモデル- #ゲーム理論 #gametheory #数学
 
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
東京工業大学 環境・社会理工学院 建築学系 大学院入学入試・進学説明会2024_v2
 
The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024The_Five_Books_Overview_Presentation_2024
The_Five_Books_Overview_Presentation_2024
 
TokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentationTokyoTechGraduateExaminationPresentation
TokyoTechGraduateExaminationPresentation
 
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
ゲーム理論 BASIC 演習106 -価格の交渉ゲーム-#ゲーム理論 #gametheory #数学
 

基本概念