block by timelyportfolio 6ffa22e7582b364f0385

newest version of d3treeR view of htmlwidgets and their Github stars

Full Screen

A new iteration of this gist with the new function d3tree2 from d3treeR as discussed in this post Week 29 | d3treeR v2.

new fun.aggregate in treemap

This version also integrates the new very nice fun.aggregate function in treemap (see issue #18), so colors at the aggregated levels are based on weighted.mean.

Code to Reproduce

# need the devel versions of treemap and d3treeR
#devtools::install_github("mtennekes/treemap")
#devtools::install_github("timelyportfolio/d3treeR")

library(dplyr)
library(treemap)
library(d3treeR)

# have a look at htmlwidgets gallery star count tree map
widget_gh = jsonlite::fromJSON("https://rawgit.com/hafen/htmlwidgetsgallery/gh-pages/github_meta.json")
widget_yaml = yaml::yaml.load_file("https://rawgit.com/hafen/htmlwidgetsgallery/gh-pages/_config.yml")

lapply(
  names(widget_gh)
  ,function(w){
    widget = NULL
    widget = Filter(function(x){x$"name" == strsplit(w,"_")[[1]][2]}, widget_yaml$widgets)
    if( !is.null(widget) && length(widget) >0 ){
      widget = widget[[1]]
      data.frame(
        author = widget$ghauthor
        ,widget = widget$name
        #,cran = paste0("CRAN = ",!is.null(widget$cran))
        ,stars = widget_gh[[w]]$stargazers_count
        ,forks = widget_gh[[w]]$forks_count
        ,stringsAsFactors = FALSE
      )
    }
  }
) %>%
  bind_rows %>%
  treemap(
    index = c("author","widget")
    ,vSize = "stars"
    ,vColor = "stars"
    ,type = "value"
    ,fun.aggregate = "weighted.mean"
  ) %>%
  d3tree2( rootname = "htmlwidgets" )