Grab Twitter search data using R and export to a tab delimited file

Standard

In this blog-post, we would see how you can grab Twitter search data using R and then export it to tab delimited file. Here are the steps:

1) First up, if we do not have R – you can install it by following the tutorial: Let’s install R Studio and R on windows machine

2) Instal Package: TwitteR if you haven’t

3) Look at the following code, modify the path in line #4 for write.table:

> require(twitteR)

> tweets <- searchTwitter(“#excel”,n=1500)

> tweetdataframe <- do.call(“rbind”,lapply(tweets,as.data.frame))

> write.table(tweetdataframe,”c:/users/paras/desktop/tweetsaboutexcel.txt”,sep=”\t”)

4) so now you have tab delimited file having about 1500 tweets!

1500 tweets R excel tab delimited RStudio code

You can also export the tweets to Excel spreadsheet, SPSS and SAS. Check this out: quick R Exporting Data

Conclusion:

In this blog-post, we saw how you can grab 1500 tweets using R and then export it to a tab delimited file.

Advertisements

8 thoughts on “Grab Twitter search data using R and export to a tab delimited file

  1. Reegan Prabhu G

    tweetdataframe <- do.call(“rbind”,lapply(tweets,as.data.frame))
    Error: unexpected input in "tweetdataframe <- do.call(“"

    help me to solve this error.

    Like

Thank this author by sharing the article on social media. If you have any questions or comments, please leave a reply below:

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s