Visualize your Github stats (forks and watchers) in a browser with R!

So OpenCPU is pretty awesome. You can run R in a browser using URL calls with an alphanumeric code (e.g., x3e50ee0780) defining a stored function, and any arguments you pass to it. Go here to store a function. And you can output lots of different types of things: png, pdf, json, etc - see here. Here’s a function I created (originally from https://gist.github.com/2602432): # Store a function with man lines # Go Here: http://beta.opencpu.org/apps/opencpu.demo/storefunction/ # number: x3e50ee0780 # link: http://beta.opencpu.org/R/call/store:tmp/x3e50ee0780/png?id='ropensci'&type='org' the <- function (id = 'hadley', type = 'user') { require(RCurl); require(RJSONIO); require(ggplot2); require(reshape2); require(plyr) if(type == 'user'){ url = "https://api.github.com/users/" } else if(type == 'org'){ url = "https://api.github.com/orgs/" } else stop("parameter 'type' has to be either 'user' or 'org' ") url2 <- paste(url, id, "/repos?per_page=100", sep = "") xx <- getURL(url2) tt <- fromJSON(xx) if(!length(tt) == 1) { tt <- tt } else { stop("user or organization not found - search GitHub? - https://github.com/") } out <- ldply(tt, function(x) t(c(x$name, x$forks, x$watchers))) names(out) <- c("Repo", "Forks", "Watchers") out$Forks <- as.integer(out$Forks) out$Watchers <- as.integer(out$Watcher) out2 <- melt(out, id = 1) out2$value <- as.numeric(out2$value) out2$Repo <- as.factor(out2$Repo) repoorder <- unique(out2[order(out2$value, decreasing=FALSE),][,1]) out2$Repo <- factor(out2$Repo, levels = repoorder) ggplot(out2, aes(Repo, value)) + geom_bar() + coord_flip() + facet_wrap(~variable) + theme_bw(base_size = 18) } the() # default for hadley the(id='defunkt', type='user') # works - a user with even more repos than Hadley the(id='ropensci', type='org') # works - organization example the(id='jeroenooms', type='user') # works - organization example the(id='SChamberlain', type='org') # error message - mismatch of username with org type the(id='adsff', type='user') # error message - name does not exist It makes a ggplot2 graphic of your watchers and forks on each repo (up to 100 repos), sorted by descending number of forks/watchers. ...

May 5, 2012 · 2 min · Scott Chamberlain

mvabund - new R pkg for multivariate abundance data

There is a new R package in town, mvabund, which does, as they say “statistical methods for analysing multivariate abundance data”. The authors introduced the paper in an online early paper in Methods in Ecology and Evolution here, R package here. The package is meant to visualize data, fit predictive models, check model assumptions, and test hypotheses about community-environment associations. Here is a quick example (originally from https://gist.github.com/2112141) #### mvabund play # install mvabund from CRAN pkg repository install.packages("mvabund") require(mvabund) # plot abundance by copepod species data(Tasmania) attach(Tasmania) tasmvabund <- mvabund(Tasmania$copepods) plot(tasmvabund ~ treatment, col = as.numeric(block)) # fit negative binomial model for each species and plot residuals vs. fitted tas.nb <- manyglm(copepods ~ block*treatment, family="negative.binomial") plot(tas.nb) ...

March 19, 2012 · 1 min · Scott Chamberlain

Journal Articles Need Interactive Graphics

I should have thought of it earlier: In a day and age when we are increasingly reading scientific literature on computer screens, why is it that we limit our peer-reviewed data representation to static, unchanging graphs and plots? Why do we not try to create dynamic visualizations of our rich and varied data sets? Would we not derive benefits in the quality and clarity of scientific discourse from publishing these visualizations? ...

February 25, 2012 · 4 min · Pascal Mickelson