Top 10

The top 10 most popular posts on this site according to Google Analytics (calculated on the traffic from 2015-04-01 till 2015-07-01):

  1. using-aggregate-and-apply-in-r
  2. using-the-r_twitter-package
  3. on-curve-fitting
  4. combinations-and-permutations-in-r
  5. making-a-heatmap-with-r
  6. handling-big-data-in-r
  7. creating-a-correlation-matrix-with-r
  8. creating-a-coverage-plot-in-r
  9. getting-started-with-tophat
  10. iranges-and-genomicranges

Top 10

RGoogleAnalytics

Download the RGoogleAnalytics package and install the package.

library("RGoogleAnalytics")
query <- QueryBuilder()
access_token <- query$authorize()
ga <- RGoogleAnalytics()
ga.profiles <- ga$GetProfileData(access_token)

start <- '2015-04-01'
end <- '2015-07-01'

#create query for page views with some metrics
query$Init(start.date = start,
           end.date = end,
           dimensions="ga:pagePath",
           metrics="ga:pageviews,ga:uniquePageviews,ga:timeOnPage,ga:bounces,ga:entrances,ga:exits",
           sort="-ga:pageviews",
           max.results = 200,
           table.id = paste("ga:",ga.profiles$id[2],sep="",collapse=","),
           access_token=access_token)

ga.data <- ga$GetReportData(query)
head(ga.data,n=3)
                                          pagePath pageviews uniquePageviews timeOnPage
1 /muse/2013/05/22/using-aggregate-and-apply-in-r/      7650            7131     266031
2    /muse/2013/04/06/using-the-r_twitter-package/      5764            4760     470954
3               /muse/2013/05/09/on-curve-fitting/      4718            4160     261399
  bounces entrances exits
1    6411      7063  6963
2    3696      4689  4635
3    3481      4083  4032

#top 10
#grep pattern is for posts only
grep(pattern="/muse/2", x=head(ga.data$pagePath,n=13), value=T)
 [1] "/muse/2013/05/22/using-aggregate-and-apply-in-r/"      
 [2] "/muse/2013/04/06/using-the-r_twitter-package/"         
 [3] "/muse/2013/05/09/on-curve-fitting/"                    
 [4] "/muse/2013/09/09/combinations-and-permutations-in-r/"  
 [5] "/muse/2010/12/06/making-a-heatmap-with-r/"             
 [6] "/muse/2013/09/03/handling-big-data-in-r/"              
 [7] "/muse/2012/01/31/creating-a-correlation-matrix-with-r/"
 [8] "/muse/2013/09/07/creating-a-coverage-plot-in-r/"       
 [9] "/muse/2012/05/09/getting-started-with-tophat/"         
[10] "/muse/2013/01/02/iranges-and-genomicranges/"           
[11] "/muse/2014/03/06/understanding-bam-flags/"             
[12] "/muse/2013/08/15/distance-matrix-computation/"

top10 <- grep(pattern="/muse/2", x=head(ga.data$pagePath,n=13), value=T)

#function for hyperlink
hyperlink <- function(x){
  link <- paste('<li><a href="http://davetang.org', x, '"', sep='')
  text <- t(as.data.frame(strsplit(x, '/')))
  link <- paste(link, '>', text[,6], '</a></li>', sep='')
  print(link)
}

hyperlink(top10)
Print Friendly
One comment Add yours

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.