• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Japan.R #2 Introduction to R
 

Japan.R #2 Introduction to R

on

  • 4,976 views

 

Statistics

Views

Total Views
4,976
Views on SlideShare
1,915
Embed Views
3,061

Actions

Likes
4
Downloads
27
Comments
0

11 Embeds 3,061

http://m884.hateblo.jp 2999
https://twitter.com 21
http://a0.twimg.com 15
http://paper.li 15
http://webcache.googleusercontent.com 5
http://cache.yahoofs.jp 1
http://reader.aol.com 1
https://si0.twimg.com 1
http://twitter.com 1
http://tweetedtimes.com 1
http://www.feedspot.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Japan.R #2 Introduction to R Japan.R #2 Introduction to R Presentation Transcript

    • Japan.R #2 @ 2011-11-26Saturday, November 26, 11 2
    • 0.Saturday, November 26, 11 3
    • (SAKAUE, Tatsuya) • : ... • Nagoya.R / HiRoshima.R • ID: sakaue • ...Saturday, November 26, 11 5
    • Saturday, November 26, 11 6
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 8
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 9
    • • • 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 •Saturday, November 26, 11 10
    • Saturday, November 26, 11 11
    • • IBM SPSS Statistics 10 ... • •Saturday, November 26, 11 12
    • • • • • •Saturday, November 26, 11 13
    • UgeeeeeeeeeSaturday, November 26, 11 14
    • Excel SPSS ... • • • Excel •Saturday, November 26, 11 15
    • Excel SPSSSaturday, November 26, 11 16
    • -Install / Update / Uninstall-Saturday, November 26, 11 17
    • 1. http://www.r-project.org/ 2. “download R” 3. JAPAN 4. OSSaturday, November 26, 11 18
    • • 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)Saturday, November 26, 11 19
    • Saturday, November 26, 11 20
    • Saturday, November 26, 11 21
    • Saturday, November 26, 11 22
    • Saturday, November 26, 11 23
    • Saturday, November 26, 11 24
    • Saturday, November 26, 11 25
    • 1. http://www.r-project.org/ 2. 3.Saturday, November 26, 11 26
    • • • • Windows •Saturday, November 26, 11 27
    • • Windows • [ Windows XP] → • [ Windows 7 ] → • Mac OS X • /Applications /Library Frameworks R. framework CleanAppSaturday, November 26, 11 28
    • • Windows • START → Program → R → R 2.14.0 • Mac OS X • /Applications R RSaturday, November 26, 11 29
    • • Windows Mac OS X 1. q() 2. 3. RSaturday, November 26, 11 30
    • • OK • Win • [ ]→[GUI ] • Font [MS Mincho]Saturday, November 26, 11 31
    • ... • 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/)Saturday, November 26, 11 32
    • • • • help(sth) !!Saturday, November 26, 11 33
    • Excel SPSSSaturday, November 26, 11 34
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 35
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 36
    • Saturday, November 26, 11 37
    • • [Enter] • > 3+5 [Enter] • > 10-3 [Enter] • > 2*3 [Enter] • > 100/20 [Enter] • > (12 + 34 -56) * 78 / 90 [Enter]Saturday, November 26, 11 38
    • • • > 100^1/2 • > 100^(1/2)Saturday, November 26, 11 39
    • Saturday, November 26, 11 40
    • Saturday, November 26, 11 41
    • Saturday, November 26, 11 42
    • “I dont know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/Saturday, November 26, 11 43
    • Saturday, November 26, 11 44
    • sqrt() • > sqrt(2) • > sqrt(144) • > sqrt(104976) •[ ]2 • 2 3 1 • > 2^(1/3)Saturday, November 26, 11 45
    • ( ) • •q() help(sth) •Saturday, November 26, 11 46
    • Saturday, November 26, 11 47
    • Saturday, November 26, 11 48
    • Saturday, November 26, 11 49
    • Saturday, November 26, 11 50
    • Saturday, November 26, 11 51
    • “I dont know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/Saturday, November 26, 11 52
    • Saturday, November 26, 11 53
    • “hako” • > hako <- c(1,2,3,4,5) • > hako • c() concatenate/combine •Saturday, November 26, 11 54
    • c() “<-” hako <- c(1,2,3,4,5) “<-” ←Saturday, November 26, 11 55
    • + ... • [Enter] • [STOP] • [Esc]Saturday, November 26, 11 56
    • • • TabSaturday, November 26, 11 57
    • hako 1 5 5Saturday, November 26, 11 58
    • Saturday, November 26, 11 59
    • • > sqrt(hako) • > log(hako)Saturday, November 26, 11 60
    • sqrt(1), sqrt(2) ... sqrt(5) log(1), log (2) ... log (5)Saturday, November 26, 11 61
    • Saturday, November 26, 11 62
    • Saturday, November 26, 11 63
    • • summary() • table() • sum() • length()Saturday, November 26, 11 64
    • • mean() • max(), min() • median() • sd()Saturday, November 26, 11 65
    • •R • • q(), help(), sqrt(), log(), c() •Saturday, November 26, 11 66
    • OKSaturday, November 26, 11 67
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 68
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 69
    • Sub topics 1. 2. 3.Saturday, November 26, 11 70
    • Saturday, November 26, 11 71
    • Saturday, November 26, 11 72
    • ... • • • TOEICSaturday, November 26, 11 73
    • ... A 180 75 B 170 65 C 165 60 D 175 70 E 190 80Saturday, November 26, 11 74
    • RSaturday, November 26, 11 75
    • Saturday, November 26, 11 76
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 77
    • Saturday, November 26, 11 78
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 79
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 80
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 81
    • Saturday, November 26, 11 82
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 83
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 84
    • 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 85
    • Saturday, November 26, 11 86
    • matrix()Saturday, November 26, 11 87
    • matrix() • • matrix( , , ) •Saturday, November 26, 11 88
    • A 180 75 B 170 65 C 165 60 D 175 70 E 190 80Saturday, November 26, 11 89
    • karada <- matrix(c(180, 170, 165, 175, 190, 75, 65, 60, 70, 80), 5, 2) 1. c() 2. matrix() • 5 2 3. karadaSaturday, November 26, 11 90
    • > karadaSaturday, November 26, 11 91
    • matrix(1:9,nrow=3,ncol=3) 1 4 7 2 5 8 3 6 9Saturday, November 26, 11 92
    • matrix(1:9,nrow=3,ncol=3,byrow=TRUE) 1 2 3 4 5 6 7 8 9Saturday, November 26, 11 93
    • 1. 2.Saturday, November 26, 11 94
    • demo <- matrix(1:30,nrow=5,ncol=6) http://gyazo.com/76c58d5d6c8426a44f160897cda99671.pngSaturday, November 26, 11 95
    • 2 → demo[2,] 2 → demo[,2] http://gyazo.com/6726084afd9e1cc4b03df85fe6bc0f29.pngSaturday, November 26, 11 96
    • 2 4 → demo[c(2,4),] 2 4 → demo[, c(2,4)]Saturday, November 26, 11 97
    • http://gyazo.com/a116c0e2f1284ea7d38bf7024d92f1cc.pngSaturday, November 26, 11 98
    • • • •Saturday, November 26, 11 99
    • Sub topics 1. 2. 3.Saturday, November 26, 11 100
    • • • •Saturday, November 26, 11 101
    • B 175 65 B 177 70 B 174 75 A 179 70 O 170 60Saturday, November 26, 11 102
    • • Excel WS • •Saturday, November 26, 11 103
    • ... • data.frame() (p.240) • (p.243) • (p.243)Saturday, November 26, 11 104
    • ...Saturday, November 26, 11 105
    • “173.365 - Come on, feel the noise” by Je the Trojan http://www. ickr.com/photos/trojanguy/3046207115/Saturday, November 26, 11 106
    • Saturday, November 26, 11 107
    • Sub topics 1. 2. 3.Saturday, November 26, 11 108
    • Saturday, November 26, 11 109
    • ... • Excel • →Saturday, November 26, 11 110
    • • ... • •Saturday, November 26, 11 111
    • • Windows → • “MyDocuments” • Mac OS X → • Linux up to you...Saturday, November 26, 11 112
    • • • getwd() • > getwd() • setwd() • > setwd("/Users/sakaue/Desktop/")Saturday, November 26, 11 113
    • • read.csv() • CSV • CSV: Comma Separated ValueSaturday, November 26, 11 114
    • 1. demo.csv • XLS/XLSX • CSV UTF-8 2. > test <- read.csv(“demo.csv”) 3. > test [Enter]Saturday, November 26, 11 115
    • CSV ...Saturday, November 26, 11 116
    • • read.delim() • • delim: delimiterSaturday, November 26, 11 117
    • 1. demo.xls 2. > test2 <- read.delim("clipboard") Mac : read.delim(pipe(“pbpaste”)) 3. > test2 [Enter]Saturday, November 26, 11 118
    • > table(test2[,1]) • 1 > mean(test2[,2]) • 2 > hist(test2[,2]) • 2Saturday, November 26, 11 119
    • • • CSV read.csv() • orSaturday, November 26, 11 120
    • CSV Excel “y2.d175 | Lasershow! Relax!” by B Rosen http://www.flickr.com/photos/rosengrant/4751386872/Saturday, November 26, 11 121
    • Excel SPSSSaturday, November 26, 11 122
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 123
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 124
    • Saturday, November 26, 11 125
    • Saturday, November 26, 11 126
    • 1. 2.Saturday, November 26, 11 127
    • 2 Excel SPSS ... orzSaturday, November 26, 11 128
    • Saturday, November 26, 11 129
    • > age <- c(18, 23, 14, 19, 21, 29, 22, 21, 23, 19, 20, 20, 26, 18, 14, 6, 8, 16, 23, 20) > hist(age)Saturday, November 26, 11 130
    • Saturday, November 26, 11 131
    • > 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)Saturday, November 26, 11 132
    • Saturday, November 26, 11 133
    • > 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"))Saturday, November 26, 11 134
    • 1. 2. 3. twitter, FBSaturday, November 26, 11 135
    • Excel “y2.d175 | Lasershow! Relax!” by B Rosen http://www.flickr.com/photos/rosengrant/4751386872/Saturday, November 26, 11 136
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 137
    • Agenda 1. R 2. 3. 4. 5. RSaturday, November 26, 11 138
    • Saturday, November 26, 11 139
    • tSaturday, November 26, 11 140
    • tSaturday, November 26, 11 141
    • t, χ2, FSaturday, November 26, 11 142
    • t t.test()Saturday, November 26, 11 143
    • 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)Saturday, November 26, 11 144
    • 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.0Saturday, November 26, 11 145
    • t ... “ t Welch t Welch t ” http://aoki2.si.gunma-u.ac.jp/lecture/Average/bunsan1.htmlSaturday, November 26, 11 146
    • Welch !Saturday, November 26, 11 147
    • ! ! ― 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 Students 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.htmlSaturday, November 26, 11 148
    • ... > 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.0Saturday, November 26, 11 149
    • t t ... •t t ... • Student t t • s^2 s t ... • %E3%82%B4%E3%82%BB%E3%83%83%E3%83%88 http://ja.wikipedia.org/wiki/%E3%82%A6%E3%82%A3%E3%83%AA%E3%82%A2%E3%83%A0%E3%83%BB • 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.htmlSaturday, November 26, 11 150
    • tSaturday, November 26, 11 151
    • Saturday, November 26, 11 152
    • • • • A B •Saturday, November 26, 11 153
    • : “ ” “however” 109 347 8 493 [ ] , .... [ ] ..., , .... [ ] ..., .Saturday, November 26, 11 154
    • > 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.htmSaturday, November 26, 11 155
    • tSaturday, November 26, 11 156
    • Saturday, November 26, 11 157
    • •3 •t • ANOVA ANalysis Of VAriance •F FSaturday, November 26, 11 158
    • 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 9Saturday, November 26, 11 159
    • > 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 1Saturday, November 26, 11 160
    • Saturday, November 26, 11 161
    • Saturday, November 26, 11 162
    • One more thing...Saturday, November 26, 11 163
    • Hi oshima.Saturday, November 26, 11 164
    • HiRoshima.R • R • 2-3 • • ...Saturday, November 26, 11 165
    • HiRoshima.R • ... • R • Tsukuba.R / Tokyo.R / Osaka.R / Nagoya.R • Internet (computer) literacy • ...Saturday, November 26, 11 166
    • HiRoshima.R •R • HiRoshima.R • !!Saturday, November 26, 11 168
    • 1 22 14% 23% 64%Saturday, November 26, 11 169
    • HiRoshima.R • →Lightning Talks • •Saturday, November 26, 11 171
    • HiRoshima.R • • R R • • • •Saturday, November 26, 11 172
    • HiRoshima.R • + Speaker !! • • • •R •RSaturday, November 26, 11 173
    • HiRoshima.R • • 1 • 2 #1 • 3 Lightning Talks •Saturday, November 26, 11 174
    • •Speaker • • Lightning Talks • R OK • 5 OKSaturday, November 26, 11 176
    • •Feedback • blog / twitter • #HiRoshimaR @sakaue •Saturday, November 26, 11 177
    • Saturday, November 26, 11 178
    • Saturday, November 26, 11 179
    • Saturday, November 26, 11 180
    • 2,940 1,785 3,780Saturday, November 26, 11 181
    • Excel SPSSSaturday, November 26, 11 182
    • twitter: @sakaue e-mail: tsakaue<AT>hiroshima-u.ac.jpSaturday, November 26, 11 183