SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
R



sesejun@is.ocha.ac.jp
     2010/10/14
R

• http://r-project.org/   DL
  • Mac, Win, Linux
•          S-Plus
•
• Interactive shell
•
•                    :)
•                              Applications
                         R
    •    Version             2.6 (
                     )
    •    R project            DL


•                              1+1[RET]


> 1+1                                > 8/3
[1] 2                                [1] 2.666667
> 3*6                                > as.integer(8/3)
[1] 18                               [1] 2
> 3^3                                > 8%%3
[1] 27                               [1] 2
&
           > c(1,2,3)
           [1] 1 2 3

> x <- 2   > c(1,2,3) + c(4,5,6)
> y <- 3   [1] 5 7 9
> x*y      > c(1,2,3) * c(4,5,6)
[1] 6      [1] 4 10 18
> x^y
[1] 8
           > c(1,2,3) * 2
           [1] 2 4 6
           > c(1,2,3) / 2
           [1] 0.5 1.0 1.5

           > v <- c(1,2,3)
           > w <- v + 3
           > w
           [1] 4 5 6
           > v*w
           [1] 4 10 18
> v <- c(3,2,5,7,2,4,3,1,4)

> length(v)
[1] 9
> max(v)
[1] 7
> min(v)
[1] 1
> mean(v)
[1] 3.444444
> median(v)
[1] 3
> unique(v)
[1] 3 2 5 7 4 1
> sort(v)
[1] 1 2 2 3 3 4 4 5 7
> order(v)
[1] 8 2 5 1 7 6 9 3 4

> hist(v)
> help(max)
> v <- c(3,2,5,7,2,4,3,1,4)

> hist(v, main="My First Histgram", col="gray")
> hist(v, col="gray", main="My First Histgram")

> w <- sort(v)
> plot(v,w)
> plot(w,v)
> seq(1,4)
[1] 1 2 3 4
> 1:4
[1] 1 2 3 4
> seq(1,5,by=2)
[1] 1 3 5
> rep(1,4)
[1] 1 1 1 1
> rep(1:3,2)
[1] 1 2 3 1 2 3

> v <- c(3,2,5,7,2,4,3,1,4)
> v[1]
[1] 3
> v[c(1,3,5)]
[1] 3 5 2
> v[c(5,3,1)]
[1] 2 5 3

> v[c(F,F,T,T,F,F,T,T,F)]
[1] 5 7 3 1
> x   <- 3
> x
[1]   3
> x   == 3
[1]   TRUE
> x   == 5
[1]   FALSE
> x   < 5
[1]   TRUE

> v <- c(3,2,5,7,2,4,3,1,4)
> v == c(3,3,3,3,3,3,3,3,3)
[1] TRUE FALSE FALSE FALSE
FALSE FALSE TRUE FALSE FALSE
> v == 3
[1] TRUE FALSE FALSE FALSE
FALSE FALSE TRUE FALSE FALSE


> v < 3
[1] FALSE TRUE FALSE FALSE
TRUE FALSE FALSE TRUE FALSE
> v <- c(3,2,5,7,2,4,3,1,4)
> v < 3
[1] FALSE TRUE FALSE FALSE
TRUE FALSE FALSE TRUE FALSE
> v[v<3]
[1] 2 2 1
> v[v>3]
[1] 5 7 4 4
> v[v>3 & v<7]
[1] 5 4 4

> (1:length(v))[v<3]
[1] 2 5 8

> sum(v>3)
[1] 4

> v %in% c(2,3,4)
[1] TRUE TRUE FALSE FALSE
TRUE TRUE TRUE FALSE TRUE
> v[v %in% c(2,3,4)]
[1] 3 2 2 4 3 4
> runif(10,min=0,max=1)
 [1] 0.45189074 0.15543373 0.04654874 0.56946222 0.06086409
 [6] 0.64340708 0.91820279 0.28365751 0.91056890 0.61600679
>   n <- 10
>   hist(runif(n,min=0,max=1), main=paste("n=",n,sep=""))
>   n <- 10000
>   hist(runif(n,min=0,max=1), main=paste("n=",n,sep=""))
.
> n <- 10
> x <- runif(n,min=0,max=1)
> x
 [1] 0.9308879 0.6457174 0.7480667 0.9277555 0.2432229 0.7852049
 [7] 0.9005295 0.3948717 0.3442392 0.7808671
> x < 0.3
 [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
> sum(x < 0.3)
[1] 1
> sum(x < 0.3)/n
[1] 0.1

> n <- 10000
> x <- runif(n,min=0,max=1)
> sum(x < 0.3)/n
[1] 0.3013

> n <- 10000
> x <- rnorm(n,mean=0,sd=1)
> sum(x < 0.3)/n
[1] 0.6125
> sum(x > 1.0)/n
[1] 0.1591
> m <- matrix((1:9)**2,nrow=3)
> m
     [,1] [,2] [,3]
[1,]    1   16   49
[2,]    4   25   64
[3,]    9   36   81
> m[c(2,3),c(2,3)]
     [,1] [,2]
[1,]    25   64
[2,]    36   81
> m[2,]
[1] 4 25 64
> m[c(1,2),]
     [,1] [,2] [,3]
[1,]     1   16  49
[2,]     4   25  64
> m[,2]
[1] 16 25 36
> m<50
     [,1] [,2] [,3]
[1,] TRUE TRUE TRUE
[2,] TRUE TRUE FALSE
[3,] TRUE TRUE FALSE
> m <- matrix((1:9)**2,nrow=3)
> solve(m)
           [,1]     [,2]        [,3]
[1,] 1.291667 -2.166667 0.9305556
[2,] -1.166667 1.666667 -0.6111111
[3,] 0.375000 -0.500000 0.1805556
> eigen(m)
$values
[1] 112.9839325 -6.2879696     0.3040371

$vectors
           [,1]       [,2]       [,3]
[1,] -0.3993327 -0.8494260 0.7612507
[2,] -0.5511074 -0.4511993 -0.6195403
[3,] -0.7326760 0.2736690 0.1914866



> v <- c(3,2,5,7,2,4,3,1,4)
> t(v) %*% v
     [,1]
[1,] 133
R
•   R                                               ≠



•
    •        if          for
•                                                          R


    •
    •   apply family (
                               R   apply, sapply, lapply       )
    •
•
•   R



                                       WEB
•   R-Tips:
    •   http://cse.naro.affrc.go.jp/takezawa/r-tips/r.html
•   RjpWiki
    •   http://www.okada.jp.org/RWiki/



•   R

Más contenido relacionado

La actualidad más candente

Surds & indices in business mathematics
Surds & indices in business mathematics Surds & indices in business mathematics
Surds & indices in business mathematics
Dr. Trilok Kumar Jain
 
Compfuncdiff
CompfuncdiffCompfuncdiff
Compfuncdiff
dianenz
 

La actualidad más candente (19)

ロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズロマンティックな9つの数 #ロマ数ボーイズ
ロマンティックな9つの数 #ロマ数ボーイズ
 
素数は孤独じゃない(番外編) 第13回 数学カフェ「素数!!」
素数は孤独じゃない(番外編) 第13回 数学カフェ「素数!!」素数は孤独じゃない(番外編) 第13回 数学カフェ「素数!!」
素数は孤独じゃない(番外編) 第13回 数学カフェ「素数!!」
 
ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ゲーム理論BASIC 演習7 -シャープレイ値を求める-ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ゲーム理論BASIC 演習7 -シャープレイ値を求める-
 
Surds & indices in business mathematics
Surds & indices in business mathematics Surds & indices in business mathematics
Surds & indices in business mathematics
 
9 chap
9 chap9 chap
9 chap
 
Data Types
Data TypesData Types
Data Types
 
Data types
Data typesData types
Data types
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
Niem khuccuoi kyam
Niem khuccuoi kyamNiem khuccuoi kyam
Niem khuccuoi kyam
 
ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ゲーム理論BASIC 演習30 -左右の靴ゲーム-ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ゲーム理論BASIC 演習30 -左右の靴ゲーム-
 
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
ゲーム理論BASIC 第20回 -無限回繰り返しゲーム-
 
Kaggle Google Quest Q&A Labeling 反省会 LT資料 47th place solution
Kaggle Google Quest Q&A Labeling 反省会 LT資料 47th place solutionKaggle Google Quest Q&A Labeling 反省会 LT資料 47th place solution
Kaggle Google Quest Q&A Labeling 反省会 LT資料 47th place solution
 
2621008 - C++ 4
2621008 -  C++ 42621008 -  C++ 4
2621008 - C++ 4
 
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
 
Compfuncdiff
CompfuncdiffCompfuncdiff
Compfuncdiff
 
ゲーム理論BASIC 演習5 -カーネルを求める-
ゲーム理論BASIC 演習5 -カーネルを求める-ゲーム理論BASIC 演習5 -カーネルを求める-
ゲーム理論BASIC 演習5 -カーネルを求める-
 
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
 
Longest common sub sequence & 0/1 Knapsack
Longest common sub sequence & 0/1 KnapsackLongest common sub sequence & 0/1 Knapsack
Longest common sub sequence & 0/1 Knapsack
 
統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半統計的学習の基礎 4章 前半
統計的学習の基礎 4章 前半
 

Destacado (8)

Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga
 
Datamining R 2nd
Datamining R 2ndDatamining R 2nd
Datamining R 2nd
 
R crash course
R crash courseR crash course
R crash course
 
SQLBits Module 2 RStats Introduction to R and Statistics
SQLBits Module 2 RStats Introduction to R and StatisticsSQLBits Module 2 RStats Introduction to R and Statistics
SQLBits Module 2 RStats Introduction to R and Statistics
 
Datamining 4th adaboost
Datamining 4th adaboostDatamining 4th adaboost
Datamining 4th adaboost
 
R - Software Estatistico
R - Software EstatisticoR - Software Estatistico
R - Software Estatistico
 
Step By Step Guide to Learn R
Step By Step Guide to Learn RStep By Step Guide to Learn R
Step By Step Guide to Learn R
 
ロジスティック回帰の考え方・使い方 - TokyoR #33
ロジスティック回帰の考え方・使い方 - TokyoR #33ロジスティック回帰の考え方・使い方 - TokyoR #33
ロジスティック回帰の考え方・使い方 - TokyoR #33
 

Similar a Datamining r 1st

Datamining r 4th
Datamining r 4thDatamining r 4th
Datamining r 4th
sesejun
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
rantd
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
Lei Kang
 

Similar a Datamining r 1st (20)

第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
 
第2回 基本演算,データ型の基礎,ベクトルの操作方法
第2回 基本演算,データ型の基礎,ベクトルの操作方法第2回 基本演算,データ型の基礎,ベクトルの操作方法
第2回 基本演算,データ型の基礎,ベクトルの操作方法
 
R programming language
R programming languageR programming language
R programming language
 
MATLAB ARRAYS
MATLAB ARRAYSMATLAB ARRAYS
MATLAB ARRAYS
 
Slides ads ia
Slides ads iaSlides ads ia
Slides ads ia
 
Datamining r 4th
Datamining r 4thDatamining r 4th
Datamining r 4th
 
Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...Attention-Based Adaptive Selection of Operations for Image Restoration in the...
Attention-Based Adaptive Selection of Operations for Image Restoration in the...
 
[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2[1062BPY12001] Data analysis with R / week 2
[1062BPY12001] Data analysis with R / week 2
 
IA-advanced-R
IA-advanced-RIA-advanced-R
IA-advanced-R
 
RではじめるTwitter解析
RではじめるTwitter解析RではじめるTwitter解析
RではじめるTwitter解析
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
 
R Matrix Math Quick Reference
R Matrix Math Quick ReferenceR Matrix Math Quick Reference
R Matrix Math Quick Reference
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
 
Extending Operators in Perl with Operator::Util
Extending Operators in Perl with Operator::UtilExtending Operators in Perl with Operator::Util
Extending Operators in Perl with Operator::Util
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
 
Data Munging in R - Chicago R User Group
Data Munging in R - Chicago R User GroupData Munging in R - Chicago R User Group
Data Munging in R - Chicago R User Group
 
Factoring common monomial
Factoring common monomialFactoring common monomial
Factoring common monomial
 
Hiroaki Shiokawa
Hiroaki ShiokawaHiroaki Shiokawa
Hiroaki Shiokawa
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.Data Science for Folks Without (or With!) a Ph.D.
Data Science for Folks Without (or With!) a Ph.D.
 

Más de sesejun

次世代シーケンサが求める機械学習
次世代シーケンサが求める機械学習次世代シーケンサが求める機械学習
次世代シーケンサが求める機械学習
sesejun
 
20110524zurichngs 2nd pub
20110524zurichngs 2nd pub20110524zurichngs 2nd pub
20110524zurichngs 2nd pub
sesejun
 
20110524zurichngs 1st pub
20110524zurichngs 1st pub20110524zurichngs 1st pub
20110524zurichngs 1st pub
sesejun
 
20110214nips2010 read
20110214nips2010 read20110214nips2010 read
20110214nips2010 read
sesejun
 
Datamining 9th association_rule.key
Datamining 9th association_rule.keyDatamining 9th association_rule.key
Datamining 9th association_rule.key
sesejun
 
Datamining 8th hclustering
Datamining 8th hclusteringDatamining 8th hclustering
Datamining 8th hclustering
sesejun
 
Datamining r 3rd
Datamining r 3rdDatamining r 3rd
Datamining r 3rd
sesejun
 
Datamining r 2nd
Datamining r 2ndDatamining r 2nd
Datamining r 2nd
sesejun
 
Datamining 6th svm
Datamining 6th svmDatamining 6th svm
Datamining 6th svm
sesejun
 
Datamining 5th knn
Datamining 5th knnDatamining 5th knn
Datamining 5th knn
sesejun
 
Datamining 3rd naivebayes
Datamining 3rd naivebayesDatamining 3rd naivebayes
Datamining 3rd naivebayes
sesejun
 
Datamining 2nd decisiontree
Datamining 2nd decisiontreeDatamining 2nd decisiontree
Datamining 2nd decisiontree
sesejun
 
Datamining 7th kmeans
Datamining 7th kmeansDatamining 7th kmeans
Datamining 7th kmeans
sesejun
 
100401 Bioinfoinfra
100401 Bioinfoinfra100401 Bioinfoinfra
100401 Bioinfoinfra
sesejun
 
Datamining 8th Hclustering
Datamining 8th HclusteringDatamining 8th Hclustering
Datamining 8th Hclustering
sesejun
 
Datamining 9th Association Rule
Datamining 9th Association RuleDatamining 9th Association Rule
Datamining 9th Association Rule
sesejun
 
Datamining 9th Association Rule
Datamining 9th Association RuleDatamining 9th Association Rule
Datamining 9th Association Rule
sesejun
 

Más de sesejun (20)

RNAseqによる変動遺伝子抽出の統計: A Review
RNAseqによる変動遺伝子抽出の統計: A ReviewRNAseqによる変動遺伝子抽出の統計: A Review
RNAseqによる変動遺伝子抽出の統計: A Review
 
バイオインフォマティクスによる遺伝子発現解析
バイオインフォマティクスによる遺伝子発現解析バイオインフォマティクスによる遺伝子発現解析
バイオインフォマティクスによる遺伝子発現解析
 
次世代シーケンサが求める機械学習
次世代シーケンサが求める機械学習次世代シーケンサが求める機械学習
次世代シーケンサが求める機械学習
 
20110602labseminar pub
20110602labseminar pub20110602labseminar pub
20110602labseminar pub
 
20110524zurichngs 2nd pub
20110524zurichngs 2nd pub20110524zurichngs 2nd pub
20110524zurichngs 2nd pub
 
20110524zurichngs 1st pub
20110524zurichngs 1st pub20110524zurichngs 1st pub
20110524zurichngs 1st pub
 
20110214nips2010 read
20110214nips2010 read20110214nips2010 read
20110214nips2010 read
 
Datamining 9th association_rule.key
Datamining 9th association_rule.keyDatamining 9th association_rule.key
Datamining 9th association_rule.key
 
Datamining 8th hclustering
Datamining 8th hclusteringDatamining 8th hclustering
Datamining 8th hclustering
 
Datamining r 3rd
Datamining r 3rdDatamining r 3rd
Datamining r 3rd
 
Datamining r 2nd
Datamining r 2ndDatamining r 2nd
Datamining r 2nd
 
Datamining 6th svm
Datamining 6th svmDatamining 6th svm
Datamining 6th svm
 
Datamining 5th knn
Datamining 5th knnDatamining 5th knn
Datamining 5th knn
 
Datamining 3rd naivebayes
Datamining 3rd naivebayesDatamining 3rd naivebayes
Datamining 3rd naivebayes
 
Datamining 2nd decisiontree
Datamining 2nd decisiontreeDatamining 2nd decisiontree
Datamining 2nd decisiontree
 
Datamining 7th kmeans
Datamining 7th kmeansDatamining 7th kmeans
Datamining 7th kmeans
 
100401 Bioinfoinfra
100401 Bioinfoinfra100401 Bioinfoinfra
100401 Bioinfoinfra
 
Datamining 8th Hclustering
Datamining 8th HclusteringDatamining 8th Hclustering
Datamining 8th Hclustering
 
Datamining 9th Association Rule
Datamining 9th Association RuleDatamining 9th Association Rule
Datamining 9th Association Rule
 
Datamining 9th Association Rule
Datamining 9th Association RuleDatamining 9th Association Rule
Datamining 9th Association Rule
 

Datamining r 1st

  • 2. R • http://r-project.org/ DL • Mac, Win, Linux • S-Plus • • Interactive shell • • :)
  • 3. Applications R • Version 2.6 ( ) • R project DL • 1+1[RET] > 1+1 > 8/3 [1] 2 [1] 2.666667 > 3*6 > as.integer(8/3) [1] 18 [1] 2 > 3^3 > 8%%3 [1] 27 [1] 2
  • 4. & > c(1,2,3) [1] 1 2 3 > x <- 2 > c(1,2,3) + c(4,5,6) > y <- 3 [1] 5 7 9 > x*y > c(1,2,3) * c(4,5,6) [1] 6 [1] 4 10 18 > x^y [1] 8 > c(1,2,3) * 2 [1] 2 4 6 > c(1,2,3) / 2 [1] 0.5 1.0 1.5 > v <- c(1,2,3) > w <- v + 3 > w [1] 4 5 6 > v*w [1] 4 10 18
  • 5. > v <- c(3,2,5,7,2,4,3,1,4) > length(v) [1] 9 > max(v) [1] 7 > min(v) [1] 1 > mean(v) [1] 3.444444 > median(v) [1] 3 > unique(v) [1] 3 2 5 7 4 1 > sort(v) [1] 1 2 2 3 3 4 4 5 7 > order(v) [1] 8 2 5 1 7 6 9 3 4 > hist(v) > help(max)
  • 6. > v <- c(3,2,5,7,2,4,3,1,4) > hist(v, main="My First Histgram", col="gray") > hist(v, col="gray", main="My First Histgram") > w <- sort(v) > plot(v,w) > plot(w,v)
  • 7. > seq(1,4) [1] 1 2 3 4 > 1:4 [1] 1 2 3 4 > seq(1,5,by=2) [1] 1 3 5 > rep(1,4) [1] 1 1 1 1 > rep(1:3,2) [1] 1 2 3 1 2 3 > v <- c(3,2,5,7,2,4,3,1,4) > v[1] [1] 3 > v[c(1,3,5)] [1] 3 5 2 > v[c(5,3,1)] [1] 2 5 3 > v[c(F,F,T,T,F,F,T,T,F)] [1] 5 7 3 1
  • 8. > x <- 3 > x [1] 3 > x == 3 [1] TRUE > x == 5 [1] FALSE > x < 5 [1] TRUE > v <- c(3,2,5,7,2,4,3,1,4) > v == c(3,3,3,3,3,3,3,3,3) [1] TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE > v == 3 [1] TRUE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE > v < 3 [1] FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE
  • 9. > v <- c(3,2,5,7,2,4,3,1,4) > v < 3 [1] FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE > v[v<3] [1] 2 2 1 > v[v>3] [1] 5 7 4 4 > v[v>3 & v<7] [1] 5 4 4 > (1:length(v))[v<3] [1] 2 5 8 > sum(v>3) [1] 4 > v %in% c(2,3,4) [1] TRUE TRUE FALSE FALSE TRUE TRUE TRUE FALSE TRUE > v[v %in% c(2,3,4)] [1] 3 2 2 4 3 4
  • 10. > runif(10,min=0,max=1) [1] 0.45189074 0.15543373 0.04654874 0.56946222 0.06086409 [6] 0.64340708 0.91820279 0.28365751 0.91056890 0.61600679 > n <- 10 > hist(runif(n,min=0,max=1), main=paste("n=",n,sep="")) > n <- 10000 > hist(runif(n,min=0,max=1), main=paste("n=",n,sep=""))
  • 11. . > n <- 10 > x <- runif(n,min=0,max=1) > x [1] 0.9308879 0.6457174 0.7480667 0.9277555 0.2432229 0.7852049 [7] 0.9005295 0.3948717 0.3442392 0.7808671 > x < 0.3 [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE > sum(x < 0.3) [1] 1 > sum(x < 0.3)/n [1] 0.1 > n <- 10000 > x <- runif(n,min=0,max=1) > sum(x < 0.3)/n [1] 0.3013 > n <- 10000 > x <- rnorm(n,mean=0,sd=1) > sum(x < 0.3)/n [1] 0.6125 > sum(x > 1.0)/n [1] 0.1591
  • 12. > m <- matrix((1:9)**2,nrow=3) > m [,1] [,2] [,3] [1,] 1 16 49 [2,] 4 25 64 [3,] 9 36 81 > m[c(2,3),c(2,3)] [,1] [,2] [1,] 25 64 [2,] 36 81 > m[2,] [1] 4 25 64 > m[c(1,2),] [,1] [,2] [,3] [1,] 1 16 49 [2,] 4 25 64 > m[,2] [1] 16 25 36 > m<50 [,1] [,2] [,3] [1,] TRUE TRUE TRUE [2,] TRUE TRUE FALSE [3,] TRUE TRUE FALSE
  • 13. > m <- matrix((1:9)**2,nrow=3) > solve(m) [,1] [,2] [,3] [1,] 1.291667 -2.166667 0.9305556 [2,] -1.166667 1.666667 -0.6111111 [3,] 0.375000 -0.500000 0.1805556 > eigen(m) $values [1] 112.9839325 -6.2879696 0.3040371 $vectors [,1] [,2] [,3] [1,] -0.3993327 -0.8494260 0.7612507 [2,] -0.5511074 -0.4511993 -0.6195403 [3,] -0.7326760 0.2736690 0.1914866 > v <- c(3,2,5,7,2,4,3,1,4) > t(v) %*% v [,1] [1,] 133
  • 14. R • R ≠ • • if for • R • • apply family ( R apply, sapply, lapply ) • •
  • 15. R WEB • R-Tips: • http://cse.naro.affrc.go.jp/takezawa/r-tips/r.html • RjpWiki • http://www.okada.jp.org/RWiki/ • R