searchTwitter (twitteR package)

searchTwitter(searchString, n=25)
Retrieve tweets that contain a particular string.
  • searchString – A character string of a username, not case-sensitive.
  • n – The number of messages to retrieve.

Example. The Michigan (and Arizona) GOP primaries were last night and I hadn’t checked news sites before writing this post, so I queried Twitter to find the results.
> library(twitteR)
Loading required package: RCurl
Loading required package: bitops
Loading required package: RJSONIO
> result <- searchTwitter("Michigan", 10)
> length(result)
[1] 10
> result
[1] "ollybarratt: VIDEO: Romney wins key victories in
Arizona and Michigan our
@simonmarksFSN reports on significance."

[1] "ShakoDjedi: Romney survives
Michigan  (from @cnn)"

[1] "sexxybeast1973: RT @GuardianUS: Mitt Romney's
decisive Michigan win won't be enough to oust Obama"

[1] "legaleagle29: Michigan Fuels Fire!"

[1] "toptw_nba: RT @umichbball: Michigan State's loss
to Indiana keeps Michigan in the hunt for the B1G
title. U-M needs to win out and OSU needs to defeat
MSU #GoBlue"

[1] "Judigal: RT @pollinsider: Santorum not over-run
in Michigan. Romn + PACs spent $3.1, Santo + PACs
spent $2.1. Gap equalized by conserv radio and Dems
300K in anti-Rom"

[1] "CommieSOB: RT @LOLGOP: The good news is Michigan
will get a chance to vote against Romney in November."

[1] "BarbieKayB: RT @Lakecrazy: for everyone saying
Mitt won Michigan by 3%.. it was 2.7%. in his
\"home\" state. Ladies and Gentlemen of up coming
states, Please vote #Newt"

[1] "frankjg_jr: RT @DailyCaller: Mitt-chigan Man:
Romney overtakes Santorum to win GOP primary -"

[1] "kevinyrock: @kim_com45 I sort of figured haha.
it's nasty outside this morning.  At least up here in
michigan it is"
Tip. Additional arguments may be specified to grab tweets in a certain date range or geographic area via since, until, and geocode.

Leave a Reply