I was looking through twitter posts and came across one dealing with a presentation at the Quatified Self Bay Area Meetup by John Schrom. Watching the video Mr. Schrom described how he acquired his personal checkin data from Foursquare via an R program. Looking further I noted that the information about the presentation included a link to his personal site included a link to his Github repository of the code that he used to gather his personal Foursquare history. With this information in hand I figured that I would attempt to data mine my own checkin data.
The repo's readme file contained the steps that he took to get a Foursquare app setup and obtain his access code to his checkin history. After following the steps I was ready for the next step.
Then, I installed R and proceeded to add the packages that John's code required. First you will need RCurl. I issued the following command in R:
install.packages("RCurl", dependencies = TRUE)
However, I found that I needed to install libcurl due to the following error: ERROR: configuration failed for package 'RCurl'
So here is what I did to remedy the problem:
sudo apt-get install libcurl4-openssl-dev
Next, I installed the rjson package via:
install.packages("rjson", dependencies = TRUE)
Then I pulled down the rpi.R and secrets.R files and per the Github readme I ran:
source('rpi.R');
checkins <- getFoursquare('YOUR_ACCESS_TOKEN_HERE');
After this I wrote the function output to a CSV file:
out <- file("output.csv", "wt")
write.table(checkins, file=out)
Looking at the rpi.R code, I noted the getFoursquare function includes the createdAt attribute of the checkin object (of the Foursquare API which states the createdAt attribute is "Seconds since epoch when this checkin was created"). Since this element is in the form of the number of seconds, for example 1376335108, and it is a data item that I want, I will need to convert it into a human, readalbe format.
This was simple enough for me since I use Open Office to view CSV files in that I found this handy formula to convert the data to a human readable date/time:
=(CellIdHere/86400)+25569+(-4/24)
From the CSV file I can inspect the checkin history for correlations with other data or look for patterns that before the review I was unaware existed.
Finally, next steps could also include learning more R to visualize the data via plotting the data into charts and graphs.
No comments:
Post a Comment