tweetsToMongo: Parses and exports tweets to a Mongo DB collection, adding...

Description Usage Arguments Author(s) Examples

Description

tweetsToMongo read tweets in JSON format (downloaded e.g. using the filterStream function in the streamR package), creates an index and other fields that can facilitate their analysis, and stores them in a MongoDB collection

Usage

1
2
tweetsToMongo(file.name = NULL, ns = NULL, host = "localhost",
  username = "", password = "", verbose = TRUE)

Arguments

file.name

string, name of the file where tweets were written.

ns

string, namespace of the collection to which tweets will be added. Generally, it will be of the form "database.collection". If the database or the collection do not exist, they will be automatically created; if they exist, tweets will be appended.

host

string host/port where mongo database is hosted. Default is localhost (127.0.0.1).

username

string, username to be used for authentication purposes with MongoDB.

password

string, password corresponding to the given username.

Author(s)

Pablo Barbera pablo.barbera@nyu.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
## Not run: 

## An example of an authenticated request using the ROAuth package,
## where consumerkey and consumer secret are fictitious.
## You can obtain your own at dev.twitter.com
  library(ROAuth)
  requestURL <- "https://api.twitter.com/oauth/request_token"
  accessURL <- "http://api.twitter.com/oauth/access_token"
  authURL <- "http://api.twitter.com/oauth/authorize"
  consumerKey <- "xxxxxyyyyyzzzzzz"
  consumerSecret <- "xxxxxxyyyyyzzzzzzz111111222222"
  my_oauth <- OAuthFactory$new(consumerKey=consumerKey,
    consumerSecret=consumerSecret, requestURL=requestURL,
    accessURL=accessURL, authURL=authURL)
  my_oauth$handshake(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl"))

## capture 10 tweets mentioning the "Rstats" hashtag
  library(streamR)
  filterStream( file.name="tweets_rstats.json",
     track="rstats", tweets=10, oauth=my_oauth )

## exporting those 10 tweets to MongoDB (database name is "tweets" and
## collection name is "rstates")
  tweetsToMongo( file.name="tweets_rstats.json", ns="tweets.rstats",
      username="<USERNAME>", password="<PASSWORD>")


## End(Not run)

SMAPPNYU/smappR documentation built on May 9, 2019, 11:19 a.m.