SlideShare a Scribd company logo
1 of 166
Download to read offline
Hi                           oshima.


                          2012-02-11 HiRoshima.R #2 @



Friday, February 10, 12                                 1
0.

Friday, February 10, 12        2
0.

         •                               (SAKAUE, Tatsuya)

                     •        :               ...
                     •    Nagoya.R / HiRoshima.R
                     •    ID: sakaue
                     •            ...



Friday, February 10, 12                                      4
Friday, February 10, 12   5
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   7
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   8
•
          •                        Ross Ihaka & Robert Gentleman (R & R)
                          •   Ross Ihaka and Robert Gentleman. R: A language for data analysis and graphics.
                              Journal of Computational and Graphical Statistics, 5(3):299-314, 1996.

                          •   http://biostat.mc.vanderbilt.edu/twiki/pub/Main/Je reyHorner/JCGSR.pdf


          •

Friday, February 10, 12                                                                                        9
Friday, February 10, 12   10
•               IBM SPSS Statistics   10   ...


          •
          •
Friday, February 10, 12                                    11
•
                          •
                          •
                •
                          •

Friday, February 10, 12       12
Ugeeeeeeeee




Friday, February 10, 12                 13
Excel     SPSS   ...
         •
         •
                          • Excel
         •
Friday, February 10, 12                          14
Excel
                          SPSS
Friday, February 10, 12           15
-Install / Update / Uninstall-



Friday, February 10, 12                  16
1. http://www.r-project.org/
            2. “download R”
            3. JAPAN
            4.                OS


Friday, February 10, 12                    17
• Windows: : http://cran.md.tsukuba.ac.jp/bin/windows/base/
                          • Download R 2.14.0 for Windows

             • Mac OS X: http://cran.md.tsukuba.ac.jp/bin/macosx/
                          • R-2.14.0.pkg (latest version)



Friday, February 10, 12                                                    18
Friday, February 10, 12   19
Friday, February 10, 12   20
Friday, February 10, 12   21
Friday, February 10, 12   22
Friday, February 10, 12   23
Friday, February 10, 12   24
1. http://www.r-project.org/
                    2.

                    3.


Friday, February 10, 12                            25
•

                          •

             •                Windows
                          •


Friday, February 10, 12                 26
• Windows
          • [ Windows XP]          →

          • [ Windows 7 ]         →


    • Mac OS X
          • /Applications                      /Library
                   Frameworks   R. framework       CleanApp


Friday, February 10, 12                                       27
• Windows
             • START → Program → R → R 2.14.1
       • Mac OS X
             • /Applications   R


                          R

Friday, February 10, 12                         28
• Windows       Mac OS X
                  1. q()
                  2.
                  3.           R


Friday, February 10, 12               29
...
                 •        help(sth)
                 • seekR  (http://seekr.jp/)


                 • R SEEK  (http://www.rseek.org/)


                 • RjpWiki    (http://www.okada.jp.org/RWiki/)


                 • R-Tips (http://cse.naro.a rc.go.jp/takezawa/r-tips/r.html)


                 •R                              (http://aoki2.si.gunma-u.ac.jp/R/)




Friday, February 10, 12                                                               30
•
              •
              •           help(sth) !!


Friday, February 10, 12                  31
Excel
                          SPSS
Friday, February 10, 12           32
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   33
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   34
Friday, February 10, 12   35
•                    [Enter]
                          • > 3+5 [Enter]
                          • > 10-3 [Enter]
                          • > 2*3 [Enter]
                          • > 100/20 [Enter]
                          • > (12 + 34 -56) * 78 / 90 [Enter]
Friday, February 10, 12                                         36
•
                          •   > 100^1/2
                          •   > 100^(1/2)
Friday, February 10, 12                     37
Friday, February 10, 12   38
Friday, February 10, 12   39
Friday, February 10, 12   40
“I don't know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/
Friday, February 10, 12                                                                             41
Friday, February 10, 12   42
sqrt()

                          • > sqrt(2)
                          • > sqrt(144)
                          • > sqrt(104976)
Friday, February 10, 12                      43
(   )

       •
       •q()               help(sth)

       •
Friday, February 10, 12                44
Friday, February 10, 12   45
Friday, February 10, 12   46
Friday, February 10, 12   47
Friday, February 10, 12   48
Friday, February 10, 12   49
“I don't know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/
Friday, February 10, 12                                                                             50
Friday, February 10, 12   51
“hako”

     •         > hako <- c(1,2,3,4,5)
     •         > hako
                  • c()   concatenate/combine
                  •
Friday, February 10, 12                         52
c()   “<-”

        hako <- c(1,2,3,4,5)      “<-”

                                  ←

Friday, February 10, 12                  53
+        ...


                      •              [Enter]


                          • [STOP]
                          • [Esc]

Friday, February 10, 12                              54
•
                      •   Tab


Friday, February 10, 12         55
hako


                 1        5          5



Friday, February 10, 12                  56
Friday, February 10, 12   57
•   > sqrt(hako)

                      • > log(hako)

Friday, February 10, 12                  58
sqrt(1), sqrt(2) ... sqrt(5)
                           log(1), log (2) ... log (5)

Friday, February 10, 12                                  59
Friday, February 10, 12   60
Friday, February 10, 12   61
•                    summary()

               •                  table()

               •          sum()

               •                      length()

Friday, February 10, 12                          62
•               mean()

          •                        max(), min()

          •               median()

          •                sd()


Friday, February 10, 12                           63
•R
               •
                 • q(), help(), sqrt(), log(), c()
               •
Friday, February 10, 12                              64
OK

Friday, February 10, 12        65
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   66
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   67
Sub topics

                          1.
                          2.
                          3.

Friday, February 10, 12                     68
Friday, February 10, 12   69
Friday, February 10, 12   70
...

            •
            •
            •             TOEIC

Friday, February 10, 12           71
...

                          A   180     75
                          B   170     65
                          C   165     60
                          D   175     70
                          E   190     80
Friday, February 10, 12                    72
R


Friday, February 10, 12       73
Friday, February 10, 12   74
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               75
Friday, February 10, 12   76
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               77
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               78
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               79
Friday, February 10, 12   80
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               81
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               82
1   2   3
                          4   5   6
                          7   8   9


Friday, February 10, 12               83
Friday, February 10, 12   84
matrix()

Friday, February 10, 12    85
matrix()

            •
            • matrix(         ,      ,   )

            •
Friday, February 10, 12                      86
A   180   75
                          B   170   65
                          C   165   60
                          D   175   70
                          E   190   80
Friday, February 10, 12                  87
karada <- matrix(c(180, 170, 165,
           175, 190, 75, 65, 60, 70, 80), 5, 2)
              1. c()
              2. matrix()
                          • 5   2
              3. karada

Friday, February 10, 12                           88
> karada




Friday, February 10, 12              89
matrix(1:9,nrow=3,ncol=3)


                          1       4      7
                          2       5      8
                          3       6      9

Friday, February 10, 12                           90
matrix(1:9,nrow=3,ncol=3,byrow=TRUE)


                          1   2   3
                          4   5   6
                          7   8   9

Friday, February 10, 12                   91
1.

                   2.




Friday, February 10, 12   92
demo <- matrix(1:30,nrow=5,ncol=6)




        http://gyazo.com/76c58d5d6c8426a44f160897cda99671.png

Friday, February 10, 12                                         93
2               → demo[2,]
                          2               → demo[,2]




               http://gyazo.com/6726084afd9e1cc4b03df85fe6bc0f29.png
Friday, February 10, 12                                                94
2       4
                              → demo[c(2,4),]
                          2       4
                              → demo[, c(2,4)]

Friday, February 10, 12                          95
http://gyazo.com/a116c0e2f1284ea7d38bf7024d92f1cc.png
Friday, February 10, 12                                               96
•
              •
              •

Friday, February 10, 12   97
Sub topics

                          1.
                          2.
                          3.

Friday, February 10, 12                     98
•
                    •
                    •

Friday, February 10, 12   99
B   175   65
                          B   177   70
                          B   174   75
                          A   179   70
                          O   170   60
Friday, February 10, 12                  100
• Excel   WS

                      •
                      •

Friday, February 10, 12              101
...

               • data.frame()   (p.240)

               •                (p.243)

               •                     (p.243)



Friday, February 10, 12                        102
...

Friday, February 10, 12         103
“173.365 - Come on, feel the noise” by Je the Trojan
                             http://www. ickr.com/photos/trojanguy/3046207115/
Friday, February 10, 12                                                     104
Friday, February 10, 12   105
Sub topics

                          1.
                          2.
                          3.

Friday, February 10, 12                     106
Friday, February 10, 12   107
...

                • Excel
                •
                          →


Friday, February 10, 12             108
•              ...

                          •
                          •
Friday, February 10, 12             109
• Windows            →
                  •       “MyDocuments”

               • Mac OS X           →

               • Linux up to you...

Friday, February 10, 12                   110
•
                          • getwd()
                             • > getwd()
                          • setwd()
                             •   > setwd("/Users/sakaue/Desktop/")




Friday, February 10, 12                                              111
• read.csv()
                • CSV
                • CSV: Comma Separated Value

Friday, February 10, 12                        112
1. demo.csv
                          • XLS/XLSX
                          • CSV             UTF-8

            2. > test <- read.csv(“demo.csv”)

            3. > test [Enter]


Friday, February 10, 12                             113
CSV
                                ...



Friday, February 10, 12               114
• read.delim()
                •
                • delim: delimiter

Friday, February 10, 12              115
1. demo.xls
         2. > test2 <- read.delim("clipboard")
                          Mac   : read.delim(pipe(“pbpaste”))

         3. > test2 [Enter]



Friday, February 10, 12                                         116
> table(test2[,1])
                          •              1

                    > mean(test2[,2])
                          •              2

                    > hist(test2[,2])
                          •              2


Friday, February 10, 12                      117
•
          • CSV                read.csv()

          •               or



Friday, February 10, 12                     118
CSV


                          Excel


                                  “y2.d175 | Lasershow! Relax!” by B Rosen
                                  http://www.flickr.com/photos/rosengrant/4751386872/
Friday, February 10, 12                                                          119
Excel
                          SPSS
Friday, February 10, 12           120
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   121
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   122
Friday, February 10, 12   123
Friday, February 10, 12   124
1.
                    2.



Friday, February 10, 12   125
2

                          Excel       SPSS
                                      ... orz
Friday, February 10, 12                         126
Friday, February 10, 12   127
> age <- c(18, 23, 14, 19,
                     21, 29, 22, 21, 23, 19, 20, 20,
                     26, 18, 14, 6, 8, 16, 23, 20)
                     > hist(age)

Friday, February 10, 12                                128
Friday, February 10, 12   129
> score <- c(60, 50, 72, 43, 50,
                  55, 43, 50, 85, 40)
                  > words <- c(340, 190, 465, 170,
                  130, 225,140, 310, 580, 120)
                  > plot(score,words)

Friday, February 10, 12                              130
Friday, February 10, 12   131
> high <- c(350, 285, 315, 340,
              210, 185, 120, 740, 425, 155)
              > coll <- c(365, 570, 645, 540, 645,
              665, 880, 550, 410, 585)
              > boxplot(high, coll, names=c("High", "Coll"))


Friday, February 10, 12                                        132
1.

                    2.

                    3.

                          twitter, FB

Friday, February 10, 12                 133
Excel

                          “y2.d175 | Lasershow! Relax!” by B Rosen
                          http://www.flickr.com/photos/rosengrant/4751386872/
Friday, February 10, 12                                                  134
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   135
Agenda
                          1. R
                          2.
                          3.
                          4.
                          5. R

Friday, February 10, 12                   136
Friday, February 10, 12   137
t




Friday, February 10, 12       138
t




Friday, February 10, 12       139
•                     H0

    •                     H1

    •       H0                 (t, χ2, F )

    •


Friday, February 10, 12                      140
t

                   •

                   •R     t.test()



Friday, February 10, 12              141
t
             •


      > like <- c(6,10,6,10,7,8,7,9,10,4)
      > dislike <- c(3,5,6,4,4,8,4,5,4,7)
      > t.test(like,dislike,var.equal=TRUE)




Friday, February 10, 12                       142
t
      > t.test(like,dislike,var.equal=TRUE)

              Two Sample t-test

      data: like and dislike
      t = 3.3041, df = 18, p-value = 0.003946
      alternative hypothesis: true difference in
      means is not equal to 0 #
      95 percent confidence interval: #
       0.9831754 4.4168246
      sample estimates:
      mean of x mean of y
            7.7       5.0

Friday, February 10, 12                            143
t               ...
         “
          t                    Welch           t


                   Welch           t                  ”

   http://aoki2.si.gunma-u.ac.jp/lecture/Average/bunsan1.html



Friday, February 10, 12                                     144
Welch !




Friday, February 10, 12             145
!                     !
                ―                                                           Welch                 ―


           •       http://oku.edu.mie-u.ac.jp/~okumura/blog/node/2262

           •       http://aoki2.si.gunma-u.ac.jp/lecture/BF/index.html

           •       Donald W. Zimmerman, ``Some properties of preliminary tests of equality of variances
                   in the two-sample location problem'', The Journal of General Psychology, Vol.123, pp.
                   217-231 (1996)

           •       The unequal variance t-test is an underused alternative to Student's t-test and the
                   Mann-Whitney U test -- Ruxton 17 (4): 688 -- Behavioral Ecology

           •                       :        Mann-Whitney U                           http://qdai.way-
                   nifty.com/qjes/2005/02/mannwhitneyu.html




Friday, February 10, 12                                                                                    146
...
      > t.test(like,dislike,var.equal=FALSE)

              Welch Two Sample t-test

      data: like and dislike
      t = 3.3041, df = 16.795, p-value = 0.004249
      alternative hypothesis: true difference in
      means is not equal to 0
      95 percent confidence interval:
       0.9743014 4.4256986
      sample estimates:
      mean of x mean of y
            7.7       5.0

Friday, February 10, 12                             147
t                      t                                       ...

      •       t                t                         ...

      •                                                                    Student                t
                                                                       t

      •                                                                                                   s^2
                                                        s                  t                                 ...
      •                                        http://ja.wikipedia.org/wiki/%E3%82%A6%E3%82%A3%E3%83%AA
              %E3%82%A2%E3%83%A0%E3%83%BB%E3%82%B4%E3%82%BB%E3%83%83%E3%83%88


      •                      http://ja.wikipedia.org/wiki/%E8%87%AA%E7%94%B1%E5%BA%A6

      •       http://mat.isc.chubu.ac.jp/fpr/fpr1997/0119.html

      •       http://www.pol.geophys.tohoku.ac.jp/~hanawa/ori/ori/054.html


Friday, February 10, 12                                                                                              148
t




Friday, February 10, 12       149
Friday, February 10, 12   150
•
                  •

                  •       A   B

           •

Friday, February 10, 12           151
:           “      ”
                                                               “however”




                                  109      347            8   493

                              [   ]        , ....
                              [   ] ...,         , ....
                              [   ] ...,         .

Friday, February 10, 12                                                    152
> freq <- c(109,347,8)
    > chisq.test(freq,correct=FALSE)

             Chi-squared test for given probabilities

        data:             freq
        X-squared = 391.7371, df = 2, p-value < 2.2e-16


    #                                               2
    #      http://homepage2.nifty.com/nandemoarchive/toukei_kiso/t_F_chi.htm




Friday, February 10, 12                                                        153
t




Friday, February 10, 12       154
Friday, February 10, 12   155
•3
                  •       t




            • ANOVA           ANalysis Of VAriance

            •F                       F


Friday, February 10, 12                              156
A        B       C
                              10       9       6
                               8       7       4
                               9       4       3
                               6       5       9
                               9       2       2
                               5       8       6
                               7       4       2
                               9       2       4
                               8       8       3
                              10       4       9
Friday, February 10, 12                            157
> test <- read.csv("demo.csv", head=T)
   > anova(lm(Class ~ Score, data=test))
   Analysis of Variance Table

   Response: Class
             Df Sum Sq Mean Sq F value Pr(>F)
   Score      1 5.2389 5.2389 9.9376 0.00384
   **
   Residuals 28 14.7611 0.5272
   ---
   Signif. codes:         0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1




Friday, February 10, 12                                                    158
•
                          •   t
                          •
                •                 !
                          •           ...


Friday, February 10, 12                     159
Friday, February 10, 12   160
Friday, February 10, 12   161
Friday, February 10, 12   162
Friday, February 10, 12   163
2,940   1,785   3,780

Friday, February 10, 12                   164
One more thing...



Friday, February 10, 12                       165
22       19              R




                                         R
                          R    R

          http://www.occn.zaq.ne.jp/cuhxr802/epi_20120126.pdf



Friday, February 10, 12                                         166
Excel
                          SPSS
Friday, February 10, 12           167
twitter: @sakaue

                          e-mail: tsakaue<AT>hiroshima-u.ac.jp




Friday, February 10, 12                                          168

More Related Content

More from SAKAUE, Tatsuya

MethokenOkinawa_Sakaue_LearnerCorpus
MethokenOkinawa_Sakaue_LearnerCorpusMethokenOkinawa_Sakaue_LearnerCorpus
MethokenOkinawa_Sakaue_LearnerCorpus
SAKAUE, Tatsuya
 
Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」
Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」
Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」
SAKAUE, Tatsuya
 
LET2012 ワークショップ「R による教育・言語データ処理のススメ」
LET2012 ワークショップ「R による教育・言語データ処理のススメ」LET2012 ワークショップ「R による教育・言語データ処理のススメ」
LET2012 ワークショップ「R による教育・言語データ処理のススメ」
SAKAUE, Tatsuya
 
授業外で個別学習を促進するためのポッドキャスト利用
授業外で個別学習を促進するためのポッドキャスト利用授業外で個別学習を促進するためのポッドキャスト利用
授業外で個別学習を促進するためのポッドキャスト利用
SAKAUE, Tatsuya
 
「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...
「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...
「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...
SAKAUE, Tatsuya
 
Osaka.R #7 LT: フォントのオハナシ
Osaka.R #7 LT: フォントのオハナシOsaka.R #7 LT: フォントのオハナシ
Osaka.R #7 LT: フォントのオハナシ
SAKAUE, Tatsuya
 
HiRoshima.R #2 LT by @sakaue
HiRoshima.R #2 LT by @sakaueHiRoshima.R #2 LT by @sakaue
HiRoshima.R #2 LT by @sakaue
SAKAUE, Tatsuya
 
Introduction to "R" for Language Researchers
Introduction to "R" for Language ResearchersIntroduction to "R" for Language Researchers
Introduction to "R" for Language Researchers
SAKAUE, Tatsuya
 
Japan.R #2 Introduction to R
Japan.R #2 Introduction to RJapan.R #2 Introduction to R
Japan.R #2 Introduction to R
SAKAUE, Tatsuya
 
SAKAUE & KIDA (2011) @JASELE Yamagata
SAKAUE & KIDA (2011) @JASELE Yamagata SAKAUE & KIDA (2011) @JASELE Yamagata
SAKAUE & KIDA (2011) @JASELE Yamagata
SAKAUE, Tatsuya
 

More from SAKAUE, Tatsuya (20)

MethokenOkinawa_Sakaue_LearnerCorpus
MethokenOkinawa_Sakaue_LearnerCorpusMethokenOkinawa_Sakaue_LearnerCorpus
MethokenOkinawa_Sakaue_LearnerCorpus
 
外国語教育メディア学会第54回全国研究大会ワークショップ「Rによる外国語教育データの分析と可視化の基本」
外国語教育メディア学会第54回全国研究大会ワークショップ「Rによる外国語教育データの分析と可視化の基本」外国語教育メディア学会第54回全国研究大会ワークショップ「Rによる外国語教育データの分析と可視化の基本」
外国語教育メディア学会第54回全国研究大会ワークショップ「Rによる外国語教育データの分析と可視化の基本」
 
統計解析環境Rによる統計処理の基本―検定と視覚化―
統計解析環境Rによる統計処理の基本―検定と視覚化―統計解析環境Rによる統計処理の基本―検定と視覚化―
統計解析環境Rによる統計処理の基本―検定と視覚化―
 
統計解析環境Rによる言語データの分析
統計解析環境Rによる言語データの分析統計解析環境Rによる言語データの分析
統計解析環境Rによる言語データの分析
 
ポッドキャスト利用による個別学習の支援とリスニング不安への影響
ポッドキャスト利用による個別学習の支援とリスニング不安への影響ポッドキャスト利用による個別学習の支援とリスニング不安への影響
ポッドキャスト利用による個別学習の支援とリスニング不安への影響
 
Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」
Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」
Nagoya.R #10 LT 「グラフはベクタ(ベクトル)画像で出力しようじゃありませんか」
 
ベクタ画像と PNG 画像の比較
ベクタ画像と PNG 画像の比較ベクタ画像と PNG 画像の比較
ベクタ画像と PNG 画像の比較
 
反応時間データをどう分析し図示するか
反応時間データをどう分析し図示するか反応時間データをどう分析し図示するか
反応時間データをどう分析し図示するか
 
LET2012 ワークショップ「R による教育・言語データ処理のススメ」
LET2012 ワークショップ「R による教育・言語データ処理のススメ」LET2012 ワークショップ「R による教育・言語データ処理のススメ」
LET2012 ワークショップ「R による教育・言語データ処理のススメ」
 
授業外で個別学習を促進するためのポッドキャスト利用
授業外で個別学習を促進するためのポッドキャスト利用授業外で個別学習を促進するためのポッドキャスト利用
授業外で個別学習を促進するためのポッドキャスト利用
 
R のインストール手順(LET 2012用)
R のインストール手順(LET 2012用)R のインストール手順(LET 2012用)
R のインストール手順(LET 2012用)
 
Nagoya.R #8 入門者講習資料
Nagoya.R #8 入門者講習資料Nagoya.R #8 入門者講習資料
Nagoya.R #8 入門者講習資料
 
「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...
「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...
「R による英語コーパスの処理入門―接続詞 and/but の使用実態調査を例に―」Computing Language and Culture with...
 
Osaka.R #7 LT: フォントのオハナシ
Osaka.R #7 LT: フォントのオハナシOsaka.R #7 LT: フォントのオハナシ
Osaka.R #7 LT: フォントのオハナシ
 
HiRoshima.R #2 LT by @sakaue
HiRoshima.R #2 LT by @sakaueHiRoshima.R #2 LT by @sakaue
HiRoshima.R #2 LT by @sakaue
 
Introduction to "R" for Language Researchers
Introduction to "R" for Language ResearchersIntroduction to "R" for Language Researchers
Introduction to "R" for Language Researchers
 
How2Install "R"
How2Install "R"How2Install "R"
How2Install "R"
 
Japan.R #2 Introduction to R
Japan.R #2 Introduction to RJapan.R #2 Introduction to R
Japan.R #2 Introduction to R
 
Nagoya.R #6 LT Beanplot
Nagoya.R #6 LT BeanplotNagoya.R #6 LT Beanplot
Nagoya.R #6 LT Beanplot
 
SAKAUE & KIDA (2011) @JASELE Yamagata
SAKAUE & KIDA (2011) @JASELE Yamagata SAKAUE & KIDA (2011) @JASELE Yamagata
SAKAUE & KIDA (2011) @JASELE Yamagata
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Recently uploaded (20)

ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

HiRoshima.R #2 入門者講習資料

  • 1. Hi oshima. 2012-02-11 HiRoshima.R #2 @ Friday, February 10, 12 1
  • 3. 0. • (SAKAUE, Tatsuya) • : ... • Nagoya.R / HiRoshima.R • ID: sakaue • ... Friday, February 10, 12 4
  • 5. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 7
  • 6. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 8
  • 7. • Ross Ihaka & Robert Gentleman (R & R) • Ross Ihaka and Robert Gentleman. R: A language for data analysis and graphics. Journal of Computational and Graphical Statistics, 5(3):299-314, 1996. • http://biostat.mc.vanderbilt.edu/twiki/pub/Main/Je reyHorner/JCGSR.pdf • Friday, February 10, 12 9
  • 9. IBM SPSS Statistics 10 ... • • Friday, February 10, 12 11
  • 10. • • • • Friday, February 10, 12 12
  • 12. Excel SPSS ... • • • Excel • Friday, February 10, 12 14
  • 13. Excel SPSS Friday, February 10, 12 15
  • 14. -Install / Update / Uninstall- Friday, February 10, 12 16
  • 15. 1. http://www.r-project.org/ 2. “download R” 3. JAPAN 4. OS Friday, February 10, 12 17
  • 16. • Windows: : http://cran.md.tsukuba.ac.jp/bin/windows/base/ • Download R 2.14.0 for Windows • Mac OS X: http://cran.md.tsukuba.ac.jp/bin/macosx/ • R-2.14.0.pkg (latest version) Friday, February 10, 12 18
  • 23. 1. http://www.r-project.org/ 2. 3. Friday, February 10, 12 25
  • 24. • • Windows • Friday, February 10, 12 26
  • 25. • Windows • [ Windows XP] → • [ Windows 7 ] → • Mac OS X • /Applications /Library Frameworks R. framework CleanApp Friday, February 10, 12 27
  • 26. • Windows • START → Program → R → R 2.14.1 • Mac OS X • /Applications R R Friday, February 10, 12 28
  • 27. • Windows Mac OS X 1. q() 2. 3. R Friday, February 10, 12 29
  • 28. ... • help(sth) • seekR (http://seekr.jp/) • R SEEK (http://www.rseek.org/) • RjpWiki (http://www.okada.jp.org/RWiki/) • R-Tips (http://cse.naro.a rc.go.jp/takezawa/r-tips/r.html) •R (http://aoki2.si.gunma-u.ac.jp/R/) Friday, February 10, 12 30
  • 29. • • help(sth) !! Friday, February 10, 12 31
  • 30. Excel SPSS Friday, February 10, 12 32
  • 31. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 33
  • 32. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 34
  • 34. [Enter] • > 3+5 [Enter] • > 10-3 [Enter] • > 2*3 [Enter] • > 100/20 [Enter] • > (12 + 34 -56) * 78 / 90 [Enter] Friday, February 10, 12 36
  • 35. • > 100^1/2 • > 100^(1/2) Friday, February 10, 12 37
  • 39. “I don't know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/ Friday, February 10, 12 41
  • 41. sqrt() • > sqrt(2) • > sqrt(144) • > sqrt(104976) Friday, February 10, 12 43
  • 42. ( ) • •q() help(sth) • Friday, February 10, 12 44
  • 48. “I don't know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/ Friday, February 10, 12 50
  • 50. “hako” • > hako <- c(1,2,3,4,5) • > hako • c() concatenate/combine • Friday, February 10, 12 52
  • 51. c() “<-” hako <- c(1,2,3,4,5) “<-” ← Friday, February 10, 12 53
  • 52. + ... • [Enter] • [STOP] • [Esc] Friday, February 10, 12 54
  • 53. • Tab Friday, February 10, 12 55
  • 54. hako 1 5 5 Friday, February 10, 12 56
  • 56. > sqrt(hako) • > log(hako) Friday, February 10, 12 58
  • 57. sqrt(1), sqrt(2) ... sqrt(5) log(1), log (2) ... log (5) Friday, February 10, 12 59
  • 60. summary() • table() • sum() • length() Friday, February 10, 12 62
  • 61. mean() • max(), min() • median() • sd() Friday, February 10, 12 63
  • 62. •R • • q(), help(), sqrt(), log(), c() • Friday, February 10, 12 64
  • 64. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 66
  • 65. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 67
  • 66. Sub topics 1. 2. 3. Friday, February 10, 12 68
  • 69. ... • • • TOEIC Friday, February 10, 12 71
  • 70. ... A 180 75 B 170 65 C 165 60 D 175 70 E 190 80 Friday, February 10, 12 72
  • 73. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 75
  • 75. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 77
  • 76. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 78
  • 77. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 79
  • 79. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 81
  • 80. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 82
  • 81. 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 83
  • 84. matrix() • • matrix( , , ) • Friday, February 10, 12 86
  • 85. A 180 75 B 170 65 C 165 60 D 175 70 E 190 80 Friday, February 10, 12 87
  • 86. karada <- matrix(c(180, 170, 165, 175, 190, 75, 65, 60, 70, 80), 5, 2) 1. c() 2. matrix() • 5 2 3. karada Friday, February 10, 12 88
  • 88. matrix(1:9,nrow=3,ncol=3) 1 4 7 2 5 8 3 6 9 Friday, February 10, 12 90
  • 89. matrix(1:9,nrow=3,ncol=3,byrow=TRUE) 1 2 3 4 5 6 7 8 9 Friday, February 10, 12 91
  • 90. 1. 2. Friday, February 10, 12 92
  • 91. demo <- matrix(1:30,nrow=5,ncol=6) http://gyazo.com/76c58d5d6c8426a44f160897cda99671.png Friday, February 10, 12 93
  • 92. 2 → demo[2,] 2 → demo[,2] http://gyazo.com/6726084afd9e1cc4b03df85fe6bc0f29.png Friday, February 10, 12 94
  • 93. 2 4 → demo[c(2,4),] 2 4 → demo[, c(2,4)] Friday, February 10, 12 95
  • 95. • • Friday, February 10, 12 97
  • 96. Sub topics 1. 2. 3. Friday, February 10, 12 98
  • 97. • • Friday, February 10, 12 99
  • 98. B 175 65 B 177 70 B 174 75 A 179 70 O 170 60 Friday, February 10, 12 100
  • 99. • Excel WS • • Friday, February 10, 12 101
  • 100. ... • data.frame() (p.240) • (p.243) • (p.243) Friday, February 10, 12 102
  • 102. “173.365 - Come on, feel the noise” by Je the Trojan http://www. ickr.com/photos/trojanguy/3046207115/ Friday, February 10, 12 104
  • 104. Sub topics 1. 2. 3. Friday, February 10, 12 106
  • 106. ... • Excel • → Friday, February 10, 12 108
  • 107. ... • • Friday, February 10, 12 109
  • 108. • Windows → • “MyDocuments” • Mac OS X → • Linux up to you... Friday, February 10, 12 110
  • 109. • getwd() • > getwd() • setwd() • > setwd("/Users/sakaue/Desktop/") Friday, February 10, 12 111
  • 110. • read.csv() • CSV • CSV: Comma Separated Value Friday, February 10, 12 112
  • 111. 1. demo.csv • XLS/XLSX • CSV UTF-8 2. > test <- read.csv(“demo.csv”) 3. > test [Enter] Friday, February 10, 12 113
  • 112. CSV ... Friday, February 10, 12 114
  • 113. • read.delim() • • delim: delimiter Friday, February 10, 12 115
  • 114. 1. demo.xls 2. > test2 <- read.delim("clipboard") Mac : read.delim(pipe(“pbpaste”)) 3. > test2 [Enter] Friday, February 10, 12 116
  • 115. > table(test2[,1]) • 1 > mean(test2[,2]) • 2 > hist(test2[,2]) • 2 Friday, February 10, 12 117
  • 116. • CSV read.csv() • or Friday, February 10, 12 118
  • 117. CSV Excel “y2.d175 | Lasershow! Relax!” by B Rosen http://www.flickr.com/photos/rosengrant/4751386872/ Friday, February 10, 12 119
  • 118. Excel SPSS Friday, February 10, 12 120
  • 119. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 121
  • 120. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 122
  • 123. 1. 2. Friday, February 10, 12 125
  • 124. 2 Excel SPSS ... orz Friday, February 10, 12 126
  • 126. > age <- c(18, 23, 14, 19, 21, 29, 22, 21, 23, 19, 20, 20, 26, 18, 14, 6, 8, 16, 23, 20) > hist(age) Friday, February 10, 12 128
  • 128. > score <- c(60, 50, 72, 43, 50, 55, 43, 50, 85, 40) > words <- c(340, 190, 465, 170, 130, 225,140, 310, 580, 120) > plot(score,words) Friday, February 10, 12 130
  • 130. > high <- c(350, 285, 315, 340, 210, 185, 120, 740, 425, 155) > coll <- c(365, 570, 645, 540, 645, 665, 880, 550, 410, 585) > boxplot(high, coll, names=c("High", "Coll")) Friday, February 10, 12 132
  • 131. 1. 2. 3. twitter, FB Friday, February 10, 12 133
  • 132. Excel “y2.d175 | Lasershow! Relax!” by B Rosen http://www.flickr.com/photos/rosengrant/4751386872/ Friday, February 10, 12 134
  • 133. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 135
  • 134. Agenda 1. R 2. 3. 4. 5. R Friday, February 10, 12 136
  • 138. H0 • H1 • H0 (t, χ2, F ) • Friday, February 10, 12 140
  • 139. t • •R t.test() Friday, February 10, 12 141
  • 140. t • > like <- c(6,10,6,10,7,8,7,9,10,4) > dislike <- c(3,5,6,4,4,8,4,5,4,7) > t.test(like,dislike,var.equal=TRUE) Friday, February 10, 12 142
  • 141. t > t.test(like,dislike,var.equal=TRUE) Two Sample t-test data: like and dislike t = 3.3041, df = 18, p-value = 0.003946 alternative hypothesis: true difference in means is not equal to 0 # 95 percent confidence interval: # 0.9831754 4.4168246 sample estimates: mean of x mean of y 7.7 5.0 Friday, February 10, 12 143
  • 142. t ... “ t Welch t Welch t ” http://aoki2.si.gunma-u.ac.jp/lecture/Average/bunsan1.html Friday, February 10, 12 144
  • 144. ! ! ― Welch ― • http://oku.edu.mie-u.ac.jp/~okumura/blog/node/2262 • http://aoki2.si.gunma-u.ac.jp/lecture/BF/index.html • Donald W. Zimmerman, ``Some properties of preliminary tests of equality of variances in the two-sample location problem'', The Journal of General Psychology, Vol.123, pp. 217-231 (1996) • The unequal variance t-test is an underused alternative to Student's t-test and the Mann-Whitney U test -- Ruxton 17 (4): 688 -- Behavioral Ecology • : Mann-Whitney U http://qdai.way- nifty.com/qjes/2005/02/mannwhitneyu.html Friday, February 10, 12 146
  • 145. ... > t.test(like,dislike,var.equal=FALSE) Welch Two Sample t-test data: like and dislike t = 3.3041, df = 16.795, p-value = 0.004249 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 0.9743014 4.4256986 sample estimates: mean of x mean of y 7.7 5.0 Friday, February 10, 12 147
  • 146. t t ... • t t ... • Student t t • s^2 s t ... • http://ja.wikipedia.org/wiki/%E3%82%A6%E3%82%A3%E3%83%AA %E3%82%A2%E3%83%A0%E3%83%BB%E3%82%B4%E3%82%BB%E3%83%83%E3%83%88 • http://ja.wikipedia.org/wiki/%E8%87%AA%E7%94%B1%E5%BA%A6 • http://mat.isc.chubu.ac.jp/fpr/fpr1997/0119.html • http://www.pol.geophys.tohoku.ac.jp/~hanawa/ori/ori/054.html Friday, February 10, 12 148
  • 149. • • A B • Friday, February 10, 12 151
  • 150. : “ ” “however” 109 347 8 493 [ ] , .... [ ] ..., , .... [ ] ..., . Friday, February 10, 12 152
  • 151. > freq <- c(109,347,8) > chisq.test(freq,correct=FALSE) Chi-squared test for given probabilities data: freq X-squared = 391.7371, df = 2, p-value < 2.2e-16 # 2 # http://homepage2.nifty.com/nandemoarchive/toukei_kiso/t_F_chi.htm Friday, February 10, 12 153
  • 154. •3 • t • ANOVA ANalysis Of VAriance •F F Friday, February 10, 12 156
  • 155. A B C 10 9 6 8 7 4 9 4 3 6 5 9 9 2 2 5 8 6 7 4 2 9 2 4 8 8 3 10 4 9 Friday, February 10, 12 157
  • 156. > test <- read.csv("demo.csv", head=T) > anova(lm(Class ~ Score, data=test)) Analysis of Variance Table Response: Class Df Sum Sq Mean Sq F value Pr(>F) Score 1 5.2389 5.2389 9.9376 0.00384 ** Residuals 28 14.7611 0.5272 --- Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 Friday, February 10, 12 158
  • 157. • t • • ! • ... Friday, February 10, 12 159
  • 162. 2,940 1,785 3,780 Friday, February 10, 12 164
  • 163. One more thing... Friday, February 10, 12 165
  • 164. 22 19 R R R R http://www.occn.zaq.ne.jp/cuhxr802/epi_20120126.pdf Friday, February 10, 12 166
  • 165. Excel SPSS Friday, February 10, 12 167
  • 166. twitter: @sakaue e-mail: tsakaue<AT>hiroshima-u.ac.jp Friday, February 10, 12 168