Tag Archives: data analysis

My experience doing R trainings at work

Recently, the office decided to set up a small team to manage its social media presence. Because I had somewhat encouraged the development, I was asked to work with them, at least as a facilitator.

Somewhere down the line, I suggested to some on the team that they should consider carrying out analysis of the social media data, at least beyond the metrics that were already available on most of those sites.

I quickly put together a very rudimentary, but useful, Shiny app, (not without some inspiration from this guy) just to demonstrate a bit of what was possible, and they were eager for me to train them in the use of R. I will share more about the app sometime later.

Application that plots social media data

Screenshot of the Shiny app developed for the team

My aim was (and still is) to get them to a point where they could carry out basic analyses on their own and grow from there. I tried to keep the material as basic and non-intimidating as possible – some of the students admitted to a morbid fear of statistics and I didn’t want to scare them off with anything too tough.

I consider myself a beginner still, so this experience really broadened my own understanding of the language. And I had a lot of fun doing it.

Well, I put together some slides on the training sessions and felt I should share them and hopefully get some feedback. Here they are:

  1. Introduction to R Programming
  2. R Data Structures – starting them off on vectors
  3. R Data Structures (Pt. II) – diving into the basics of data frames
  4. R Data Structures (Pt. III) – examining ways of working with matrices
  5. R Data Structures (Pt. IV) – lists (and lists)

The good thing is that some friends and colleagues (outside the office) have told me that, in the coming year, they would like me to train them as well in the use of R.

It’s only an opportunity for me to, yet, learn the more.

Leave a comment

Filed under Computers & Internet

Get to use Facebook data via R

I’ve been building a Shiny app for work in the office. I was made to head a team that does some sort of web monitoring and we’ve decided to use R for some of the analyses. Before I attempt to detail some of the work done in the past couple of months or so, I will briefly share my attempt to access Facebook data just yesterday. The package to use is called Rfacebook, co-developed and maintained by Pablo Barbera.

First, open R. If you don’t have the package installed, run the code

install.packages("Rfacebook")

and then load it using library(Rfacebook)

To use the package, you need to first get a Facebook API access token – a temporary one that works for just 2 hours or one that you can use repeatedly for different sessions. To get the former, visit https://developers.facebook.com/tools/explorer/; for a permanent token, register an app with https://developers.facebook.com/ using your Facebook account, if you have one. The instructions in the documentation are actually crisp enough to guide you through the process; to access it, run help(fboauth).

I also found this blog, where the process is given in detail. Knowing Facebook’s penchant for changing things, don’t be surprised if there are slight modifications to the guidance you find here or elsewhere!

There are 3 things you want out of this – 1. App Version 2. App ID and 3. App Secret.

Now that you have your main details ready, you may want to store your token in your working directory so that you can call it up whenever you want to collect data through the API. The Rfacebook documentation proposed something like this

app_id <- 123XXXXXXX12345
app_secret <- ABDEFXXXXXXXXXXXXXXXXXXXX9876545
token <- fboauth(app_id, app_secret)
save(token, "my_token")
# Call up token later using load("my_token")

 

This last line with save() didn’t work for me and I can’t tell why. I even tried saving it as .RData file to no avail. This is what I did

saveRDS(token, "my_token.rds")

To use it, I would then use something like

token <- readRDS("my_token.rds)

 

Having done all, I could use different functions in the package. My only disappointment was that the main function that I had looked forward to using, searchFacebook(), has been deprecated for the current API version (at the time of writing this blog, v2.8) and Facebook had already retired the version (v1.0) for which this was possible.

So, I find the package only marginally useful for now, but will experiment a little and share if I find something interesting.

2 Comments

Filed under Computers & Internet

My new R-omance

 

 

 

 

 

I gotta admit it. I’m hooked.

I recently stumbled upon this statistical programming software called R and I can’t seem to get enough of it after months of  learning about it and using it.

I think it was quite a fortuitous encounter. In the course of my work, I often called upon to do a little data management, including data analysis. I’ve done a little bit of consulting in the past in this area, and have done data analysis ranging from the old-fashioned way (punching a calculator and using statistical tables) to using software such as Epi Info and SPSS (I’ve learned a bit of STATA, but never really got to using it).

The other day, my PC, on which I had SPSS installed, was beginning to act up and all I could think of was how I was going to have to shell out some good money to get it onto a new machine, as I didn’t have the setup files.

So, it was a pleasant surprise, when I registered for a refresher MOOC on data analysis being offered by University of Texas, to discover that there was an open source application they were going to use for the course. As they put me through installation steps for R and R Studio, I was like “whaaaat?”, when I saw the IDE interface of R Studio. I am yet to recover from the experience.

The sexy R Studio Interface

The sexy R Studio Interface

I’m not going to talk about the technical aspects of R that I’ve learnt and I will resist every temptation to display any code here, but I want to recommend to my colleagues and friends, if you haven’t started using R, do so now. Take a course or something like that and get a hold of this wonderful tool. To think that I’m just discovering this now.

‘Nuff said. More on this later…

1 Comment

Filed under Computers & Internet

This post has a silly title: “Temporary Absence”

DeathtoStock_Medium10

I promised myself that I would be a little more regular with my posts on this blog. Especially since I decided to expand the scope. However, I’ve been taking this course on edX.org (Foundations in Data Analysis from University of Texas, Austin, TX) and it’s been taking my time. I thought I should just refresh my knowledge a bit in what is a basic field for anyone in public health. And I started a new romance with R and RStudio. It’s been an exhilarating experience and I’m excited everyday. I will tell you guys the story of this love affair later.

Anyhow, I have not been that conscientious with managing the time. I actually have a 5 – 6 week backlog of course work that I have to complete before the course ends the second week of February and I’ve literally been burning the midnight oil. Add to that, trying to get into business for the new year and elections that are going to start in a couple of weeks. Life is anything but dull, and totally chaotic right now!

What are you up to?

1 Comment

Filed under Lifestyle