twitteR: R Based Twitter Client

> library(twitteR)

バージョン: 1.1.9

関数名 概略
decode_short_url A function to decode shortened URLs
directMessage-class Class "directMessage": A class to represent Twitter Direct Messages
dmGet Functions to manipulate Twitter direct messages
favorites A function to get favorite tweets
friendships A function to detail relations between yourself & other users
getCurRateLimitInfo A function to retrieve current rate limit information
getTrends Functions to view Twitter trends
getUser Functions to manage Twitter users
get_latest_tweet_id A function to retrieve the most recent tweet ID from a database
import_statuses Functions to import twitteR objects from various sources
load_tweets_db Functions to persist/load twitteR data to a database
registerTwitterOAuth Register OAuth credentials to twitter R session
register_db_backend Functions to setup a database backend for twitteR
retweets Functions to work with retweets
searchTwitter Search twitter
search_twitter_and_store A function to store searched tweets to a database
setup_twitter_oauth Sets up the OAuth credentials for a twitteR session
showStatus Functions to return statuses
status-class Class to contain a Twitter status
strip_retweets A function to remove retweets
taskStatus A function to send a Twitter DM after completion of a task
twListToDF A function to convert twitteR lists to data.frames
updateStatus Functions to manipulate Twitter status
use_oauth_token Sets up the OAuth credentials for a twitteR session from an existing Token object
user-class A container object to model Twitter users
userTimeline Functions to view Twitter timelines



> sapply(c("", ""), decode_short_url)


> favorites(user = "rstudio", n = 10)
[1] "daniellequinn88: @rstudio  I can not WAIT to try this!  :D"

[1] "amcrisan: I love all the new ggplot and shiny features. Thanks @rstudio : )"

[1] "jle_beau: @timelyportfolio @jcheng @rstudio awesome, feels more like a shinyapp than an htmlwidget #rstats"

[1] "tomfaulkenberry: New this year: using RMarkdown and @github to post my course syllabi. Love being able to generate html and pdf versions quickly! @rstudio"

[1] "matlabulous: Many congrats to @timelyportfolio #rstats #GOAT 52 wks of #htmlwidget cc @ramnath_vaidya"

[1] "HoloMarkeD: Promising feature in @rstudio to create Excel macro style custom UI via addins"

[1] "xuxoramos: Just ordered these awesome @rstudio stickers from @stickermule!"

[1] "ntweetor: Finally checking out the preview version of RStudio: emacs! addins! and more! I think the holidays came early, thank you @rstudio. #rstats"

[1] "happymedium16: Discovery of the afternoon: @rstudio's cheat sheets are great resources for data management and visualization tools:"

[1] "jhollist: Just installed @rstudio server preview edition ... Can pull out source tabs to new window!!!!  This may have been there a while but THANKS!"

getTrends / availableTrendLocations


  • woeid
  • lat
  • long
  • exclude
  • ...
> availableTrendLocations() %>% head(5)
       name country woeid
1 Worldwide             1
2  Winnipeg  Canada  2972
3    Ottawa  Canada  3369
4    Quebec  Canada  3444
5  Montreal  Canada  3534
> availableTrendLocations() %>% dplyr::filter(country == "Japan") %>% 
+   .$woeid
 [1] "1110809"  "1116753"  "1117034"  "1117099"  "1117155"  "1117227" 
 [7] "1117502"  "1117545"  "1117605"  "1117817"  "1117881"  "1118072" 
[13] "1118108"  "1118129"  "1118285"  "1118370"  "1118550"  "2345896" 
[19] "15015370" "15015372" "23424856" "90036018"
> # Japan
> getTrends(woeid = 23424856) %>% 
+   dplyr::sample_n(10) %>% 
+   .$name
 [1] "支持者ら"     "ヨンフェス"   "腹上死"       "#AmebaFRESH" 
 [5] "Deemoアプデ"  "原価厨"       "パズドラX"    "#aikatsu"    
 [9] "パンスプ"     "ニュートラル"

getUser / lookupUsers

> getUser("u_ribo")
[1] "u_ribo"

searchTwitter / Rtweets



  • searchString
  • n
  • lang
  • since
  • until
  • locale
  • geocode
  • sinceID
  • maxID
  • resultType
  • retryOnRateLimit
  • ...
> searchTwitter("rstudio", n = 10)
[1] "Kee_Kun: @Linkzero @JaHIY @mlusa @OrcaXS 真写的话别用RStudio,用Jypter。但是论文的话又不用代码,老实写LaTeX不就好。"

[1] "BroVic: Shiny 0.13.0 now available on #CRAN. We shall get there :) #rstats"

[1] "siero5335: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet!"

[1] "kazutan: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet!"

[1] "StackOverflowR: Sending Rstudio view() content to different pane"

[1] "straightedge: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet!"

[1] "tggleeson: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet!"

[1] "riannone: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet!"

[1] "homeAIinfo: RT @vhe74: Shiny 0.13.0 pour faire de belles UI à vos projets R #datascience #R #Viz"

[1] "ShKlinkenberg: RT @JasonAizkalns: Shiny 0.13.0 via @rstudio #rstats Favorite = Gadgets = not just for applications, but part of yo…"



> setup_twitter_oauth(consumer_key = Sys.getenv("TWITTER_KEY"), consumer_secret = Sys.getenv("TWITTER_SECRET"))



> searchTwitter("#rstats", n = 5) %>% twListToDF() %>% 
+   knitr::kable(format = "markdown")
text favorited favoriteCount replyToSN created truncated replyToSID id replyToUID statusSource screenName retweetCount isRetweet retweeted longitude latitude
Comment modifier le nombre de décimale dans R ? :digits #Rstats #Rtips FALSE 0 NA 2016-01-21 10:17:31 FALSE NA 690116003506814976 NA Tweet Old Post Abcd_R 0 FALSE FALSE NA NA
CRAN updates: rmumps #rstats FALSE 0 NA 2016-01-21 10:13:40 FALSE NA 690115032877813764 NA CRANberries Feed CRANberriesFeed 0 FALSE FALSE NA NA
RT @hfmuehleisen: Fixed lots of bugs in MonetDBLite, even got #CRAN check to like it... @MonetDB #Rstats Info: http… FALSE 0 NA 2016-01-21 10:12:58 FALSE NA 690114858541518848 NA TweetDeck MonetDB 4 TRUE FALSE NA NA
RT @Ko_Ver: New article: #SQL2016 R Services: Executing #Rstats code in Revolution R Enterprise FALSE 0 NA 2016-01-21 10:09:20 FALSE NA 690113942727835649 NA Twitter Web Client sseewolf 3 TRUE FALSE NA NA
RT @thoughtsymmetry: .@mervealanyali presenting at our Exploring Google trends and Twitter using #rstats @thedatascilab… FALSE 0 NA 2016-01-21 10:09:03 FALSE NA 690113873551171584 NA Twitter for Android thedatascilab 4 TRUE FALSE NA NA


> userTimeline("rstudio", n = 10)
[1] "rstudio: Shiny 0.13 is out: gadgets, templates, modules, and more! #rstats #shiny"

[1] "rstudio: My week on Twitter: 107 Mentions, 126K Mention Reach, 1 Retweets. How's your audience growing? via"

[1] "rstudio: @datalies No, multidplyr uses multiple R processes via the parallel package"

[1] "rstudio: RcppParallel: Getting R and C++ to work (some more) in parallel #rstats #rcpp"

[1] "rstudio: @noamross @timelyportfolio I believe in the custom lua writer we used for ioslides we copy it into the directory to avoid an absolute path"

[1] "rstudio: @timelyportfolio @noamross you want to use html_document_base to inherit all of that machinery. see"

[1] "rstudio: RStudio Essentials Webinar Series continues in 2016 - Managing Change Part 1 (Projects). Starts in 45 min"

[1] "rstudio: @pofigster It's currently 4.4.0."