twitteRで快適Rライフ!

10,099 views

Published on

Japan.R #2のLT用スライドです

Published in: Technology, Design

twitteRで快適Rライフ!

  1. 1. twitteR R Japan.R #2 (2011/11/26) @a_bicky
  2. 2. • Takeshi Arabiki ‣ ‣ Twitter & : @a_bicky & id:a_bicky• R• http://d.hatena.ne.jp/a_bicky/
  3. 3. R Osaka.R #4 Tokyo.R #16 Tsukuba.R #9http://www.slideshare.net/abicky/twitterr http://www.slideshare.net/abicky/r-9034336 http://www.slideshare.net/abicky/r-10128090
  4. 4. R Osaka.R #4 Tokyo.R #16 Tsukuba.R #9http://www.slideshare.net/abicky/twitterr http://www.slideshare.net/abicky/r-9034336 http://www.slideshare.net/abicky/r-10128090 http://www.slideshare.net/abicky/rtwitter
  5. 5. LT
  6. 6. twitteR• RJSONIO•• ID status ID• fav favorited TRUE• truncated TRUE• DM• status character factor
  7. 7. twitteR• RJSONIO•• ID status ID• fav favorited TRUE• truncated TRUE• DM• status character factor
  8. 8. OAuth ” ” twitteR -
  9. 9. OAuth ” ” twitteR -
  10. 10. OAuth ” ” twitteR -
  11. 11. OAuth ” ” twitteR - twittoru
  12. 12. OAuth ” ” twitteR -
  13. 13. OAuth ” ” twitteR -
  14. 14. OAuth ” ” twitteR - twittoru
  15. 15. OAuth ” ” twitteR - twittoru
  16. 16. OAuth ” ” twitteR -R twittoru
  17. 17. OAuth ” ” twitteR - yokkuns twittoru
  18. 18. for Unix users
  19. 19. for Unix usersWindows
  20. 20. $ sudo R -e install.packages("twitteR")$ sudo R -e install.packages("ROAuth")
  21. 21. RJSONIO$ sudo R CMD remove RJSONIO # 0.3$ wget http://cran.r-project.org/src/contrib/Archive/RJSONIO/RJSONIO_0.3-1.tar.gz$ sudo R CMD install RJSONIO_0.3-1.tar.gz
  22. 22. twitteR ROAuth$ wget https://raw.github.com/gist/1378878 -O ROAuch.patch$ wget http://cran.r-project.org/src/contrib/ROAuth_0.9.0.tar.gz$ tar xvfz ROAuth_0.9.0.tar.gz$ patch -c -p1 -d ROAuth < ROAuth.patch$ sudo R CMD remove ROAuth$ sudo R CMD install ROAuth$ wget https://raw.github.com/gist/1378880 -O twitteR.patch$ wget http://cran.r-project.org/src/contrib/twitteR_0.99.14.tar.gz$ tar xvfz twitteR_0.99.14.tar.gz$ patch -c -p1 -d twitteR < twitteR.patch$ sudo R CMD remove twitteR$ sudo R CMD install twitteR
  23. 23. https://dev.twitter.com/
  24. 24. https://dev.twitter.com/
  25. 25. https://dev.twitter.com/
  26. 26. https://dev.twitter.com/
  27. 27. ←←← URL
  28. 28. ← Developer Rules Of The Road ← “Yes, I agree” ← URL“Create your Twitter application”
  29. 29. “twitter”
  30. 30. ← Consumer key← Consumer secret
  31. 31. “Read, Write and Access direct messages” “Update this Twitter application’s settings”
  32. 32. access token
  33. 33. access token
  34. 34. access token
  35. 35. access token ← Access token ← Access token secretRead, write, and direct messages
  36. 36. twitteRinit_twitteR.R library(twitteR) library(ROAuth) # Sys.setlocale("LC_TIME", "en_US.utf-8") # twit.oauth <- OAuthFactory$new( handshakeComplete = TRUE, signMethod = "HMAC", consumerKey = "vFIR1AYuMJN8X997BjplRw", consumerSecret = "p9ZtKxJONDdBO1rIYNiBSmXLJj3W0cKdizremBPb6T4", oauthKey = "103027920-8tmAeUQHLxIbDGmjrpJURCKQEDpxu7uHQrGLqphW", oauthSecret = "0ixZIMBDRQElQ9P2IrTNIeIvqR7zJzSp6ShNolYcbSE") # OAuth registerTwitterOAuth(twit.oauth)
  37. 37. twitteRinit_twitteR.R library(twitteR) library(ROAuth) # Sys.setlocale("LC_TIME", "en_US.utf-8") # twit.oauth <- OAuthFactory$new( handshakeComplete = TRUE, signMethod = "HMAC", consumerKey = "vFIR1AYuMJN8X997BjplRw", consumerSecret = "p9ZtKxJONDdBO1rIYNiBSmXLJj3W0cKdizremBPb6T4", oauthKey = "103027920-8tmAeUQHLxIbDGmjrpJURCKQEDpxu7uHQrGLqphW", oauthSecret = "0ixZIMBDRQElQ9P2IrTNIeIvqR7zJzSp6ShNolYcbSE") # OAuth registerTwitterOAuth(twit.oauth) ※
  38. 38. > source("init_twitteR.R")> tweet("Japan.R #japanr")
  39. 39. DM> taskStatus({+ x <- sample(as.numeric(1:100), 100000000, replace =TRUE)+ ret <- sum(x)+ }, "a_bicky", sprintf(" %s", ret))[1] 5049839571
  40. 40. DM> taskStatus({+ x <- sample(as.numeric(1:100), 100000000, replace =TRUE)+ ret <- sum(x)+ }, "a_bicky", sprintf(" %s", ret))[1] 5049839571
  41. 41. R

×