Today I write about a short but pretty interesting topic. It is about analyzing which devices the Twitter users use and show them in a pie chart.
First of all, like always, we have to go through the authentification process I described here.
But then the fun can begin.
Getting the data
We start with searching on Twitter for Tweets containing a certain keyword. For my example I used “Social Media”.
tweets = searchTwitter("Social Media", n=20, cainfo="cacert.pem")
Analyze Twitter Devices with R
We now have our tweets and just have to get the information about the source out of them. It is like searching for a string.
devices <- sapply(tweets, function(x) x$getStatusSource())
devices <- gsub("","", devices)
devices <- strsplit(devices, ">")
devices <- sapply(devices,function(x) ifelse(length(x) > 1, x, x))[/code]
Ok now we have our devices can put them in a nice looking pie chart like this one.
Sometimes you can see interesting trends in the use of devices or maybe with a lot of luck you can find a new and unknown device.