twitteR: R Based Twitter Client
- CRAN: http://cran.r-project.org/web/packages/twitteR/index.html
- GitHub: https://github.com/geoffjentry/twitteR/
- URL: http://lists.hexdump.org/listinfo.cgi/twitter-users-hexdump.org
> 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 |
decode_short_url
短縮URLの解読
> sapply(c("http://bit.ly/23226se656", "https://t.co/5f3aThB0m0"), decode_short_url)
http://bit.ly/23226se656
"http://grlfrsxe.com/hhnfhd/?src=1368"
https://t.co/5f3aThB0m0
"https://www.rstudio.com/resources/cheatsheets/"
favorites
> favorites(user = "rstudio", n = 10)
[[1]]
[1] "daniellequinn88: @rstudio I can not WAIT to try this! :D"
[[2]]
[1] "amcrisan: I love all the new ggplot and shiny features. Thanks @rstudio : )"
[[3]]
[1] "jle_beau: @timelyportfolio @jcheng @rstudio awesome, feels more like a shinyapp than an htmlwidget #rstats"
[[4]]
[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"
[[5]]
[1] "matlabulous: Many congrats to @timelyportfolio #rstats #GOAT 52 wks of #htmlwidget https://t.co/gEkU28J8Mv cc @ramnath_vaidya https://t.co/fHmnC1ScuQ"
[[6]]
[1] "HoloMarkeD: Promising feature in @rstudio to create Excel macro style custom UI via addins https://t.co/sY2UsXnGbC"
[[7]]
[1] "xuxoramos: Just ordered these awesome @rstudio stickers from @stickermule! https://t.co/bMUDK1lFHn"
[[8]]
[1] "ntweetor: Finally checking out the preview version of RStudio: emacs! addins! and more! I think the holidays came early, thank you @rstudio. #rstats"
[[9]]
[1] "happymedium16: Discovery of the afternoon: @rstudio's cheat sheets are great resources for data management and visualization tools: https://t.co/5f3aThB0m0"
[[10]]
[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
Arguments
- 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
文字列が含まれるつぶやきを検索
Arguments
- searchString
- n
- lang
- since
- until
- locale
- geocode
- sinceID
- maxID
- resultType
- retryOnRateLimit
- ...
> searchTwitter("rstudio", n = 10)
[[1]]
[1] "Kee_Kun: @Linkzero @JaHIY @mlusa @OrcaXS 真写的话别用RStudio,用Jypter。但是论文的话又不用代码,老实写LaTeX不就好。"
[[2]]
[1] "BroVic: Shiny 0.13.0 now available on #CRAN. We shall get there :) https://t.co/A1sd90T01S #rstats"
[[3]]
[1] "siero5335: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet! https://t.co/fF3SlPDISl"
[[4]]
[1] "kazutan: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet! https://t.co/fF3SlPDISl"
[[5]]
[1] "StackOverflowR: Sending Rstudio view() content to different pane https://t.co/Eh8l3iqOdn"
[[6]]
[1] "straightedge: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet! https://t.co/fF3SlPDISl"
[[7]]
[1] "tggleeson: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet! https://t.co/fF3SlPDISl"
[[8]]
[1] "riannone: RT @winston_chang: #rstats Shiny 0.13.0 is out, and is our most featureful release yet! https://t.co/fF3SlPDISl"
[[9]]
[1] "homeAIinfo: RT @vhe74: Shiny 0.13.0 pour faire de belles UI à vos projets R https://t.co/kqFUAOZDfz #datascience #R #Viz"
[[10]]
[1] "ShKlinkenberg: RT @JasonAizkalns: Shiny 0.13.0 https://t.co/JkSDDMz9Ji via @rstudio #rstats Favorite = Gadgets = not just for applications, but part of yo…"
setup_twitter_oauth
認証
> setup_twitter_oauth(consumer_key = Sys.getenv("TWITTER_KEY"), consumer_secret = Sys.getenv("TWITTER_SECRET"))
twListToDF
つぶやきデータ(リストクラス)をデータフレームに変換
> 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 https://t.co/4ik6Wmyk96 #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 https://t.co/y5W2NTKSXT #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: https://t.co/8NUvezyyjE 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 https://t.co/Ncfaluk96l | 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 https://t.co/AxvbAB… | FALSE | 0 | NA | 2016-01-21 10:09:03 | FALSE | NA | 690113873551171584 | NA | Twitter for Android | thedatascilab | 4 | TRUE | FALSE | NA | NA |
userTimeline
> userTimeline("rstudio", n = 10)
[[1]]
[1] "rstudio: Shiny 0.13 is out: gadgets, templates, modules, and more! https://t.co/tntg7jxdJx #rstats #shiny"
[[2]]
[1] "rstudio: My week on Twitter: 107 Mentions, 126K Mention Reach, 1 Retweets. How's your audience growing? via https://t.co/CB9VaXokOm"
[[3]]
[1] "rstudio: @datalies No, multidplyr uses multiple R processes via the parallel package"
[[4]]
[1] "rstudio: RcppParallel: Getting R and C++ to work (some more) in parallel https://t.co/V0BD6vJqco #rstats #rcpp"
[[5]]
[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"
[[6]]
[1] "rstudio: @timelyportfolio @noamross you want to use html_document_base to inherit all of that machinery. see https://t.co/C7csaAsfpj"
[[7]]
[1] "rstudio: RStudio Essentials Webinar Series continues in 2016 - Managing Change Part 1 (Projects). Starts in 45 min https://t.co/3VPmh54APj"
[[8]]
[1] "rstudio: @pofigster It's currently 4.4.0."