Introduction to "R" for Language Researchers

  • 463 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
463
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
11
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 40 SAKAUE Akkuş Tatsuya 2011-12-17Tuesday, December 6, 11 1
  • 2. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 7
  • 3. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 8
  • 4. • • 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 •Tuesday, December 6, 11 9
  • 5. Tuesday, December 6, 11 10
  • 6. • IBM SPSS Statistics 10 ... • •Tuesday, December 6, 11 11
  • 7. Excel SPSS ... • • • Excel •Tuesday, December 6, 11 12
  • 8. -Install / Update / Uninstall-Tuesday, December 6, 11 14
  • 9. 1. http://www.r-project.org/ 2. “download R” 3. JAPAN 4. OSTuesday, December 6, 11 15
  • 10. • 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)Tuesday, December 6, 11 16
  • 11. Tuesday, December 6, 11 17
  • 12. Tuesday, December 6, 11 18
  • 13. Tuesday, December 6, 11 19
  • 14. Tuesday, December 6, 11 20
  • 15. Tuesday, December 6, 11 21
  • 16. Tuesday, December 6, 11 22
  • 17. 1. http://www.r-project.org/ 2. 3.Tuesday, December 6, 11 23
  • 18. • • • Windows •Tuesday, December 6, 11 24
  • 19. • Windows • [ Windows XP] → • [ Windows 7 ] → • Mac OS X • /Applications /Library Frameworks R. framework CleanAppTuesday, December 6, 11 25
  • 20. • Windows • START → Program → R → R 2.14.0 • Mac OS X • /Applications R RTuesday, December 6, 11 26
  • 21. • Windows Mac OS X 1. q() 2. 3. RTuesday, December 6, 11 27
  • 22. ... • 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/)Tuesday, December 6, 11 28
  • 23. • • • help(sth) !!Tuesday, December 6, 11 29
  • 24. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 31
  • 25. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 32
  • 26. Tuesday, December 6, 11 33
  • 27. • [Enter] • > 3+5 [Enter] • > 10-3 [Enter] • > 2*3 [Enter] • > 100/20 [Enter] • > (12 + 34 -56) * 78 / 90 [Enter]Tuesday, December 6, 11 34
  • 28. Tuesday, December 6, 11 35
  • 29. Tuesday, December 6, 11 36
  • 30. “I dont know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/Tuesday, December 6, 11 37
  • 31. Tuesday, December 6, 11 38
  • 32. sqrt() • > sqrt(2) • > sqrt(144) • > sqrt(104976)Tuesday, December 6, 11 39
  • 33. ( ) • •q() help(sth) •Tuesday, December 6, 11 40
  • 34. Tuesday, December 6, 11 41
  • 35. Tuesday, December 6, 11 42
  • 36. Tuesday, December 6, 11 43
  • 37. Tuesday, December 6, 11 44
  • 38. “I dont know !” by fmgbain http://www.flickr.com/photos/fmgbain/4382010455/Tuesday, December 6, 11 45
  • 39. Tuesday, December 6, 11 46
  • 40. “hako” • > hako <- c(1,2,3,4,5) • > hako • c() concatenate/combine •Tuesday, December 6, 11 47
  • 41. c() “<-” hako <- c(1,2,3,4,5) “<-” ←Tuesday, December 6, 11 48
  • 42. + ... • [Enter] • [STOP] • [Esc]Tuesday, December 6, 11 49
  • 43. • • TabTuesday, December 6, 11 50
  • 44. hako 1 5 5Tuesday, December 6, 11 51
  • 45. Tuesday, December 6, 11 52
  • 46. • > sqrt(hako) • > log(hako)Tuesday, December 6, 11 53
  • 47. sqrt(1), sqrt(2) ... sqrt(5) log(1), log (2) ... log (5)Tuesday, December 6, 11 54
  • 48. Tuesday, December 6, 11 55
  • 49. •R • • q(), help(), sqrt(), log(), c() •Tuesday, December 6, 11 56
  • 50. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 57
  • 51. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 58
  • 52. Tuesday, December 6, 11 59
  • 53. Tuesday, December 6, 11 60
  • 54. Tuesday, December 6, 11 61
  • 55. ... • • • TOEICTuesday, December 6, 11 62
  • 56. ... A 180 75 B 170 65 C 165 60 D 175 70 E 190 80Tuesday, December 6, 11 63
  • 57. ... • Excel • →Tuesday, December 6, 11 64
  • 58. • ... • •Tuesday, December 6, 11 65
  • 59. • Windows → • “MyDocuments” • Mac OS X → • Linux up to you...Tuesday, December 6, 11 66
  • 60. • • getwd() • > getwd() • setwd() • > setwd("/Users/sakaue/Desktop/")Tuesday, December 6, 11 67
  • 61. • read.csv() • CSV • CSV: Comma Separated ValueTuesday, December 6, 11 68
  • 62. 1. demo.csv • XLS/XLSX • CSV UTF-8 2. > test <- read.csv(“demo.csv”) 3. > test [Enter]Tuesday, December 6, 11 69
  • 63. CSV ...Tuesday, December 6, 11 70
  • 64. • read.delim() • • delim: delimiterTuesday, December 6, 11 71
  • 65. 1. demo.xls 2. > test2 <- read.delim("clipboard") Mac : read.delim(pipe(“pbpaste”)) 3. > test2 [Enter]Tuesday, December 6, 11 72
  • 66. > table(test2[,1]) • 1 > mean(test2[,2]) • 2 > hist(test2[,2]) • 2Tuesday, December 6, 11 73
  • 67. • • CSV read.csv() • orTuesday, December 6, 11 74
  • 68. CSV Excel “y2.d175 | Lasershow! Relax!” by B Rosen http://www.flickr.com/photos/rosengrant/4751386872/Tuesday, December 6, 11 75
  • 69. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 77
  • 70. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 78
  • 71. Tuesday, December 6, 11 79
  • 72. Tuesday, December 6, 11 80
  • 73. 1. 2.Tuesday, December 6, 11 81
  • 74. 2 Excel SPSS ... orzTuesday, December 6, 11 82
  • 75. Tuesday, December 6, 11 83
  • 76. > age <- c(18, 23, 14, 19, 21, 29, 22, 21, 23, 19, 20, 20, 26, 18, 14, 6, 8, 16, 23, 20) > hist(age)Tuesday, December 6, 11 84
  • 77. Tuesday, December 6, 11 85
  • 78. > 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)Tuesday, December 6, 11 86
  • 79. Tuesday, December 6, 11 87
  • 80. > nns <- c(350, 285, 315, 340, 210, 185, 120, 740, 425, 155) > ns <- c(365, 570, 645, 540, 645, 665, 880, 550, 410, 585) > boxplot(nns, ns, names=c("NNS", "NS"))Tuesday, December 6, 11 88
  • 81. 1. 2. 3. twitter, FBTuesday, December 6, 11 89
  • 82. Excel “y2.d175 | Lasershow! Relax!” by B Rosen http://www.flickr.com/photos/rosengrant/4751386872/Tuesday, December 6, 11 90
  • 83. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 91
  • 84. Agenda 1. R 2. 3. 4. 5. RTuesday, December 6, 11 92
  • 85. Tuesday, December 6, 11 93
  • 86. tTuesday, December 6, 11 94
  • 87. tTuesday, December 6, 11 95
  • 88. • H0 • H1 • H0 (t, χ2, F ) •Tuesday, December 6, 11 96
  • 89. t • •R t.test()Tuesday, December 6, 11 97
  • 90. 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)Tuesday, December 6, 11 98
  • 91. 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.0Tuesday, December 6, 11 99
  • 92. Tuesday, December 6, 11 101
  • 93. • • • A B •Tuesday, December 6, 11 102
  • 94. : “however” 109 347 8 493 [ ] However, .... [ ] ..., however, .... [ ] ..., however.Tuesday, December 6, 11 103
  • 95. > 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.htmTuesday, December 6, 11 104
  • 96. • • t • • ! • ...Tuesday, December 6, 11 106
  • 97. Tuesday, December 6, 11 107
  • 98. One more thing...Tuesday, December 6, 11 108
  • 99. PackageTuesday, December 6, 11 109
  • 100. Package • • base 1,000 • package • ex. RMeCabTuesday, December 6, 11 110
  • 101. RMeCabTuesday, December 6, 11 111
  • 102. RMeCab • •R MeCab • RTuesday, December 6, 11 112
  • 103. • RMeCabText() : • RMeCabFreq() : • Ngram() : N-gram • collocate() :Tuesday, December 6, 11 114
  • 104. Tuesday, December 6, 11 115
  • 105. Tuesday, December 6, 11 117
  • 106. 2,940 1,785 3,780Tuesday, December 6, 11 119
  • 107. twitter: @sakaue e-mail: tsakaue<AT>hiroshima-u.ac.jpTuesday, December 6, 11 121