SlideShare a Scribd company logo
R



sesejun@is.ocha.ac.jp
     2009/10/1
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

More Related Content

What's hot

ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-
ssusere0a682
 
Data Types
Data TypesData Types
Data Types
Masters Academy
 
ゲーム理論BASIC 演習3 -安定集合を求める-
ゲーム理論BASIC 演習3 -安定集合を求める-ゲーム理論BASIC 演習3 -安定集合を求める-
ゲーム理論BASIC 演習3 -安定集合を求める-
ssusere0a682
 
ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-
ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-
ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-
ssusere0a682
 
Data types
Data typesData types
Data types
Masters Academy
 
Htdp01
Htdp01Htdp01
ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ゲーム理論BASIC 演習7 -シャープレイ値を求める-ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ssusere0a682
 
The chain rule
The chain ruleThe chain rule
The chain rule
Shaun Wilson
 
exam 1
exam 1exam 1
2621008 - C++ 4
2621008 -  C++ 42621008 -  C++ 4
2621008 - C++ 4
S.Ali Sadegh Zadeh
 
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
Ken'ichi Matsui
 
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
Takashi Kitano
 
ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ゲーム理論BASIC 演習30 -左右の靴ゲーム-ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ssusere0a682
 
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
Asif Shahriar
 
Compfuncdiff
CompfuncdiffCompfuncdiff
Compfuncdiff
dianenz
 
Ch10
Ch10Ch10
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips
Takashi Kitano
 
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
ssusere0a682
 

What's hot (18)

ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-ゲーム理論BASIC 演習6 -仁を求める-
ゲーム理論BASIC 演習6 -仁を求める-
 
Data Types
Data TypesData Types
Data Types
 
ゲーム理論BASIC 演習3 -安定集合を求める-
ゲーム理論BASIC 演習3 -安定集合を求める-ゲーム理論BASIC 演習3 -安定集合を求める-
ゲーム理論BASIC 演習3 -安定集合を求める-
 
ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-
ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-
ゲーム理論BASIC 演習1 -3人ゲームのナッシュ均衡+α-
 
Data types
Data typesData types
Data types
 
Htdp01
Htdp01Htdp01
Htdp01
 
ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ゲーム理論BASIC 演習7 -シャープレイ値を求める-ゲーム理論BASIC 演習7 -シャープレイ値を求める-
ゲーム理論BASIC 演習7 -シャープレイ値を求める-
 
The chain rule
The chain ruleThe chain rule
The chain rule
 
exam 1
exam 1exam 1
exam 1
 
2621008 - C++ 4
2621008 -  C++ 42621008 -  C++ 4
2621008 - C++ 4
 
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
 
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
{tidytext}と{RMeCab}によるモダンな日本語テキスト分析
 
ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ゲーム理論BASIC 演習30 -左右の靴ゲーム-ゲーム理論BASIC 演習30 -左右の靴ゲーム-
ゲーム理論BASIC 演習30 -左右の靴ゲーム-
 
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
 
Compfuncdiff
CompfuncdiffCompfuncdiff
Compfuncdiff
 
Ch10
Ch10Ch10
Ch10
 
{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips{shiny}と{leaflet}による地図アプリ開発Tips
{shiny}と{leaflet}による地図アプリ開発Tips
 
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
【演習】Re:ゲーム理論入門 第11回 -非協力ゲームにおける交渉ゲーム-
 

Viewers also liked

Connect Life - Work - Trade - Taquara - Comercialização: 55 (21) 99219-0640...
Connect  Life - Work - Trade - Taquara  - Comercialização: 55 (21) 99219-0640...Connect  Life - Work - Trade - Taquara  - Comercialização: 55 (21) 99219-0640...
Connect Life - Work - Trade - Taquara - Comercialização: 55 (21) 99219-0640...
Marcelo Silva
 
National Council Magazine 2015 Coleman article
National Council Magazine 2015 Coleman articleNational Council Magazine 2015 Coleman article
National Council Magazine 2015 Coleman article
Carol McCullough
 
MHTSEP15_pg66-68_Cendol for Soul
MHTSEP15_pg66-68_Cendol for SoulMHTSEP15_pg66-68_Cendol for Soul
MHTSEP15_pg66-68_Cendol for Soul
Lim Teck Choon
 
Ohp Seijoen H20 05 Hairetsu
Ohp Seijoen H20 05 HairetsuOhp Seijoen H20 05 Hairetsu
Ohp Seijoen H20 05 Hairetsusesejun
 
Now Vila da Penha
Now Vila da PenhaNow Vila da Penha
Now Vila da Penha
INVEXO Imobiliária
 
Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...
Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...
Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...
Marcelo Silva
 
SQL Server Data Synchronization with Office 365
SQL Server Data Synchronization with Office 365SQL Server Data Synchronization with Office 365
SQL Server Data Synchronization with Office 365
Layer2
 
Terug Naar De Kust Grontmij Juni 2008
Terug Naar De Kust Grontmij Juni 2008Terug Naar De Kust Grontmij Juni 2008
Terug Naar De Kust Grontmij Juni 2008Astrid_2010
 
Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...
Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...
Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...
Marcelo Silva
 
Sql Server Analysis Server SSAS OLAP Integration Office 365
Sql Server Analysis Server SSAS OLAP Integration Office 365Sql Server Analysis Server SSAS OLAP Integration Office 365
Sql Server Analysis Server SSAS OLAP Integration Office 365
Layer2
 
Resultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridad
Resultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridadResultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridad
Resultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridad
CSUC - Consorci de Serveis Universitaris de Catalunya
 
To a wild rose - Edward Mac Dowell
To a wild rose -  Edward Mac DowellTo a wild rose -  Edward Mac Dowell
To a wild rose - Edward Mac Dowell
david bonnin
 

Viewers also liked (15)

Connect Life - Work - Trade - Taquara - Comercialização: 55 (21) 99219-0640...
Connect  Life - Work - Trade - Taquara  - Comercialização: 55 (21) 99219-0640...Connect  Life - Work - Trade - Taquara  - Comercialização: 55 (21) 99219-0640...
Connect Life - Work - Trade - Taquara - Comercialização: 55 (21) 99219-0640...
 
National Council Magazine 2015 Coleman article
National Council Magazine 2015 Coleman articleNational Council Magazine 2015 Coleman article
National Council Magazine 2015 Coleman article
 
Plezier 2
Plezier 2Plezier 2
Plezier 2
 
K9 Handler
K9 HandlerK9 Handler
K9 Handler
 
MHTSEP15_pg66-68_Cendol for Soul
MHTSEP15_pg66-68_Cendol for SoulMHTSEP15_pg66-68_Cendol for Soul
MHTSEP15_pg66-68_Cendol for Soul
 
Ohp Seijoen H20 05 Hairetsu
Ohp Seijoen H20 05 HairetsuOhp Seijoen H20 05 Hairetsu
Ohp Seijoen H20 05 Hairetsu
 
PSS
PSSPSS
PSS
 
Now Vila da Penha
Now Vila da PenhaNow Vila da Penha
Now Vila da Penha
 
Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...
Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...
Vila das Fontes Residencial - Vila da Penha - 55 (21) 99219-0640 WhatsApp | 7...
 
SQL Server Data Synchronization with Office 365
SQL Server Data Synchronization with Office 365SQL Server Data Synchronization with Office 365
SQL Server Data Synchronization with Office 365
 
Terug Naar De Kust Grontmij Juni 2008
Terug Naar De Kust Grontmij Juni 2008Terug Naar De Kust Grontmij Juni 2008
Terug Naar De Kust Grontmij Juni 2008
 
Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...
Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...
Elegance Freguesia - Comercialização: 55 (21) 99219-0640 WhatsApp ou (21) 781...
 
Sql Server Analysis Server SSAS OLAP Integration Office 365
Sql Server Analysis Server SSAS OLAP Integration Office 365Sql Server Analysis Server SSAS OLAP Integration Office 365
Sql Server Analysis Server SSAS OLAP Integration Office 365
 
Resultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridad
Resultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridadResultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridad
Resultados del proyecto Valencia SmartCity y retos en el ámbito de la seguridad
 
To a wild rose - Edward Mac Dowell
To a wild rose -  Edward Mac DowellTo a wild rose -  Edward Mac Dowell
To a wild rose - Edward Mac Dowell
 

Similar to PRE: Datamining 2nd R

第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
第2回 基本演算,データ型の基礎,ベクトルの操作方法(解答付き)
Wataru Shito
 
第2回 基本演算,データ型の基礎,ベクトルの操作方法
第2回 基本演算,データ型の基礎,ベクトルの操作方法第2回 基本演算,データ型の基礎,ベクトルの操作方法
第2回 基本演算,データ型の基礎,ベクトルの操作方法
Wataru Shito
 
R programming language
R programming languageR programming language
R programming language
Alberto Minetti
 
MATLAB ARRAYS
MATLAB ARRAYSMATLAB ARRAYS
MATLAB ARRAYS
Aditya Choudhury
 
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...
MasanoriSuganuma
 
[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
Kevin Chun-Hsien Hsu
 
Datamining r 4th
Datamining r 4thDatamining r 4th
Datamining r 4th
sesejun
 
Slides ads ia
Slides ads iaSlides ads ia
Slides ads ia
Arthur Charpentier
 
basic mathematics practice of using R Tool
basic mathematics  practice of using R Toolbasic mathematics  practice of using R Tool
basic mathematics practice of using R Tool
SahilBhavsar5
 
IA-advanced-R
IA-advanced-RIA-advanced-R
IA-advanced-R
Arthur Charpentier
 
Datastructure tree
Datastructure treeDatastructure tree
Datastructure tree
rantd
 
R Matrix Math Quick Reference
R Matrix Math Quick ReferenceR Matrix Math Quick Reference
R Matrix Math Quick Reference
Mark Niemann-Ross
 
Useful javascript
Useful javascriptUseful javascript
Useful javascript
Lei Kang
 
RではじめるTwitter解析
RではじめるTwitter解析RではじめるTwitter解析
RではじめるTwitter解析
Takeshi Arabiki
 
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
Nova Patch
 
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
designandanalytics
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
beasiswa
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
Faraz Ahmed
 
Factoring common monomial
Factoring common monomialFactoring common monomial
Factoring common monomial
AjayQuines
 
Lec38
Lec38Lec38

Similar to PRE: Datamining 2nd R (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
 
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
 
Datamining r 4th
Datamining r 4thDatamining r 4th
Datamining r 4th
 
Slides ads ia
Slides ads iaSlides ads ia
Slides ads ia
 
basic mathematics practice of using R Tool
basic mathematics  practice of using R Toolbasic mathematics  practice of using R Tool
basic mathematics practice of using R Tool
 
IA-advanced-R
IA-advanced-RIA-advanced-R
IA-advanced-R
 
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
 
RではじめるTwitter解析
RではじめるTwitter解析RではじめるTwitter解析
RではじめるTwitter解析
 
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
 
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
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
Factoring common monomial
Factoring common monomialFactoring common monomial
Factoring common monomial
 
Lec38
Lec38Lec38
Lec38
 

More from sesejun

RNAseqによる変動遺伝子抽出の統計: A Review
RNAseqによる変動遺伝子抽出の統計: A ReviewRNAseqによる変動遺伝子抽出の統計: A Review
RNAseqによる変動遺伝子抽出の統計: A Review
sesejun
 
バイオインフォマティクスによる遺伝子発現解析
バイオインフォマティクスによる遺伝子発現解析バイオインフォマティクスによる遺伝子発現解析
バイオインフォマティクスによる遺伝子発現解析
sesejun
 
次世代シーケンサが求める機械学習
次世代シーケンサが求める機械学習次世代シーケンサが求める機械学習
次世代シーケンサが求める機械学習sesejun
 
20110602labseminar pub
20110602labseminar pub20110602labseminar pub
20110602labseminar pub
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 knnsesejun
 
Datamining 4th adaboost
Datamining 4th adaboostDatamining 4th adaboost
Datamining 4th adaboostsesejun
 
Datamining 3rd naivebayes
Datamining 3rd naivebayesDatamining 3rd naivebayes
Datamining 3rd naivebayessesejun
 
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 Bioinfoinfrasesejun
 
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
 

More from 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 4th adaboost
Datamining 4th adaboostDatamining 4th adaboost
Datamining 4th adaboost
 
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
 

Recently uploaded

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
shyamraj55
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Speck&Tech
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Zilliz
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
TIPNGVN2
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 

Recently uploaded (20)

“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with SlackLet's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
Let's Integrate MuleSoft RPA, COMPOSER, APM with AWS IDP along with Slack
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...Building RAG with self-deployed Milvus vector database and Snowpark Container...
Building RAG with self-deployed Milvus vector database and Snowpark Container...
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Data structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdfData structures and Algorithms in Python.pdf
Data structures and Algorithms in Python.pdf
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 

PRE: Datamining 2nd R

  • 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