March 7, 2014

The views of TokyoR

Yesterday, I have released the package, “slideshare”.

That package enables you to get the metadata of uploaded slides (e.g. the number of views, favorites, downloads, and so on ) through the slideshare API.

Today, I will try to visualize one of the metadata with the package.

Here's the today's work.

I have got the information of slides whose tags are “tokyor”, which is added to slides in relation to “Tokyo R user group meeting”.

So What ?

There are 65 slides tagged “TokyoR”. Seven of them have been viewed over 10,000 times.

Furthermore, the top one was viewed 30,533 times!!!

TokyoR slides have been viewed 304,521 times in total!!!

So far, about 1,500 people attended TokyoR, meaning that there are 20 times more viewers than attendees.

I hope TokyoR will keep contributing to R community.

Code

library(slideshare)
library(rCharts)
# get data
test <- Slideshare$new(apikey="XXXXXXXX",sharedsecret="XXXXXXXX")
result <- test$getSlideshowByTag("tokyor", limit=100)

# prepare for plot
result <- result[,c("Created", "NumViews", "Username", "StrippedTitle")]
colnames(result) <- c("x", "y", "Username", "Title")
result$x <- paste("#!", as.numeric(as.Date(result$x))*86400000, "!#")
result$y <- as.numeric(result$y)

# visualize
h1 <- Highcharts$new()
h1$chart(type="scatter")
for(un in unique(result$Username)){
  h1$series(data=toJSONArray2(subset(result, Username==un), json = F),
            name=un)
  }
h1$xAxis(title = list(text = "Upload date"),
         type = "datetime",
         dateTimeLabelFormats = list(month= '%Y-%b')
         )
h1$yAxis(title = list(text = "Number of views"), 
         min=0,
         label=list(format="!#'{value:,.0f}'#!")
         )
h1$legend(align = 'center', 
          verticalAlign = 'top', 
          layout = 'horizontal',
          title = list(text = "usernames"))
h1$plotOptions(scatter = list(marker = list(radius=6, symbol = 'circle')))
h1$tooltip(useHTML = T, 
           formatter = "#! function() {
           return  '<p>TITLE: ' + this.point.Title + '</p>'+
           '<p>NAME: ' + this.point.Username + '</p>'+
           '<p>DATE: ' + Highcharts.dateFormat('%Y-%m-%d', this.x) + '</p>'+
           '<p>VIEWS:' + this.y + '</p>'; } !#")
h1$title(text = "TokyoR Slides")
h1$show("iframesrc", cdn=TRUE)

No comments:

Post a Comment