Skip to main content

Posts

Showing posts from May, 2014

TweetMapping

Twitter incessantly produces copious amount of data. The locations of tweets can help with some interesting questions. One that comes to mind, and one that I plan to do when the time is right is- What part of the world is interested in The Champions League final vs The World Cup final. The rationale for this is the amount of debate currently happening on this topic.
Basically, this post will answer "where in the world are people searching for [something]?" Also, all explanation will be in the comments itself.
Code
library(ROAuth) library(twitteR) library(ggplot2) library(maps) library(dismo) # Check to see if R is connected to twitter registerTwitterOAuth(twitCred) # searchString parameter for Twitter APIkey<-"#UCLfinal"# requesting Twitter APItag<- searchTwitter(key, n=2000, lang= "en") # Tweets data frame# At this stage it is quite possible to get rid of all the non-geotagged tweets.# However, a very very small portion of users geotag tweets. …

Random2.0

This is the second version my only app in the Google Play Store that is somehow not down in the abbess. A recent comment made me realize that certain functionality in the previous version do not work on the newer Android devices. It was because the newer devices do not allow the main thread to do the background task (which is a great restriction. Kudos Android). In my case, the background task was to connect to Random.org to extract random numbers. So, I had to jettison the previous code and re-implement it using AsyncTask.
Screenshots:






Code for DIY partpackagecom.randomayush; importjava.io.BufferedReader; importjava.io.InputStreamReader; importjava.net.URL; importandroid.content.Context; importandroid.net.ConnectivityManager; importandroid.os.AsyncTask; importandroid.os.Bundle; importandroid.view.View; importandroid.view.inputmethod.InputMethodManager; importandroid.widget.Button; importandroid.widget.EditText; importandroid.widget.TextView; publicclass diy extends MainActivity …

TwitterMining

This is an austere implementation of mining tweets using R. I will work on making it better sometime in the future (once I engulf R data structures more).
Connecting to Twitter API The first step was to get consumer key and consumer secret from Twitter. This is used for authentication purposes. To get these, I just created a new app on Twitter.
Apparently, on Windows system the authentication requires an extra step. Thanks to this blog post for clarifying that. See below.

library("ROAuth") library("twitteR") #necessary step for Windows download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem") #to get your consumerKey and consumerSecret see the twitteR documentation for instructions credentials <- OAuthFactory$new (consumerKey='#################...', consumerSecret='#################...', requestURL='https://api.twitter.com/oauth…