Description Usage Arguments Details Author(s) See Also Examples
This function parses tweets downloaded using filterStream
,
sampleStream
or userStream
and returns a list.
1 | readTweets(tweets, verbose = TRUE)
|
tweets |
A character string naming the file where tweets are stored or the name of the object in memory where the tweets were saved as strings. |
verbose |
logical, default is |
This function is the first step in the parseTweets
function and
is provided now as an independent function for convenience purposes. In cases
where only one field is needed, it can be faster to extract it directly from
the JSON data read in R as a list. It can also be useful to extract fields
that are not parsed by parseTweets
, such as hashtags or mentions.
The total number of tweets that are parsed might be lower than the number of lines in the file or object that contains the tweets because blank lines, deletion notices, and incomplete tweets are ignored.
Pablo Barbera pablo.barbera@nyu.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 | ## The dataset example_tweets contains 10 public statuses published
## by @twitterapi in plain text format. The code below converts the object
## into a list and extracts only the text.
data(example_tweets)
tweets.list <- readTweets(example_tweets)
only.text <- unlist(lapply(tweets.list, '[[', 'text'))
## it can be done with an explicit loop:
only.text <- c()
for (i in 1:length(tweets.list)){
only.text[i] <- tweets.list[[i]]['text']
}
print(unlist(only.text))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.